Skip to content

Commit

Permalink
Updated max allowed length for string field NodeID to 256, and for ot…
Browse files Browse the repository at this point in the history
…her string fields to 128
  • Loading branch information
Bahubali Jain committed Oct 14, 2021
1 parent 0819669 commit dc33e12
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions middleware/specvalidator/spec_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,9 @@ func validateVolumeCapabilitiesArg(
}

const (
maxFieldString = 256
maxFieldString = 128
maxFieldMap = 4096
maxFieldNodeId = 256
)

func validateFieldSizes(msg interface{}) error {
Expand All @@ -782,11 +783,16 @@ func validateFieldSizes(msg interface{}) error {
f := rv.Field(i)
switch f.Kind() {
case reflect.String:
if l := f.Len(); l > maxFieldString {
maxFieldLen := maxFieldString
if tv.Field(i).Name == "NodeId" {
maxFieldLen = maxFieldNodeId
}

if l := f.Len(); l > maxFieldLen {
return status.Errorf(
codes.InvalidArgument,
"exceeds size limit: %s: max=%d, size=%d",
tv.Field(i).Name, maxFieldString, l)
tv.Field(i).Name, maxFieldLen, l)
}
case reflect.Map:
if f.Len() == 0 {
Expand Down

0 comments on commit dc33e12

Please sign in to comment.