Skip to content

Commit

Permalink
Version info : accept zero-length string values
Browse files Browse the repository at this point in the history
  • Loading branch information
tc-hib committed Mar 18, 2024
1 parent 5922870 commit bae858a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion version/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,10 @@ func readString(data []byte, pos *int) (string, error) {
func readStringWithLength(data []byte, pos *int, length int) (string, error) {
data = data[*pos:]

if length == 0 || length > len(data)/2 {
if length == 0 {
return "", nil
}
if length < 0 || length > len(data)/2 {
return "", errors.New(errInvalidStringLength)
}

Expand Down
Binary file modified version/testdata/TestFromBytes_ErrStringLength.golden
Binary file not shown.

0 comments on commit bae858a

Please sign in to comment.