fix(rpc2): prevent unmarshal initialized proto struct cause EOF

with #22985316

Signed-off-by: xiejian <xiejian3@oppo.com>
This commit is contained in:
xiejian 2025-01-15 17:25:18 +08:00 committed by slasher
parent 19f006b1f4
commit 83b87cb839
2 changed files with 4 additions and 4 deletions

View File

@ -86,6 +86,9 @@ func (req *Request) ParseParameter(para Unmarshaler) error {
if len(req.Parameter) > 0 {
return para.Unmarshal(req.Parameter[:])
}
if req.ContentLength == 0 {
return para.Unmarshal(nil)
}
_, err := req.Body.WriteTo(LimitWriter(Codec2Writer(para, int(req.ContentLength)), req.ContentLength))
if err != nil {
return NewError(400, "ParseParameter", err.Error())

View File

@ -783,10 +783,7 @@ func (s *shard) validateUnitUpdate(node clustermgr.ShardUnit) bool {
}
}
// prevent update shard unit not exist
if !exist {
return false
}
return true
return exist
}
func (s *shard) checkShardOptHeader(h OpHeader) error {