server/etcdserver: fix oss-fuzz issue N

This commit is contained in:
AdamKorcz 2022-02-15 15:32:31 +00:00
parent aa75fd0850
commit fad82c1b6f

View File

@ -20,6 +20,7 @@ import (
"path"
"strconv"
"time"
"unicode/utf8"
"github.com/coreos/go-semver/semver"
"go.etcd.io/etcd/pkg/v3/pbutil"
@ -123,6 +124,9 @@ func (s *EtcdServer) applyV2Request(r *RequestV2, shouldApplyV3 membership.Shoul
alternative: func() string { return fmt.Sprintf("id:%d,method:%s,path:%s", r.ID, r.Method, r.Path) },
}
defer func(start time.Time) {
if !utf8.ValidString(r.Method) {
s.lg.Panic("method is not valid utf-8")
}
success := resp.Err == nil
applySec.WithLabelValues(v2Version, r.Method, strconv.FormatBool(success)).Observe(time.Since(start).Seconds())
warnOfExpensiveRequest(s.Logger(), s.Cfg.WarningApplyDuration, start, stringer, nil, nil)