mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: check http StatusCode before unmarshal
Check http StatusCode. Only Unmarshal body if StatusCode is statusOK.
This commit is contained in:
@@ -395,6 +395,10 @@ func promoteMemberHTTP(ctx context.Context, url string, id uint64, peerRt http.R
|
||||
return nil, membership.ErrIDNotFound
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK { // all other types of errors
|
||||
return nil, fmt.Errorf("member promote: unknown error(%s)", string(b))
|
||||
}
|
||||
|
||||
var membs []*membership.Member
|
||||
if err := json.Unmarshal(b, &membs); err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user