diff --git a/version/binary.go b/version/binary.go index 5270ed0..4799cf4 100644 --- a/version/binary.go +++ b/version/binary.go @@ -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) } diff --git a/version/testdata/TestFromBytes_ErrStringLength.golden b/version/testdata/TestFromBytes_ErrStringLength.golden index 1f853a4..ad819cf 100644 Binary files a/version/testdata/TestFromBytes_ErrStringLength.golden and b/version/testdata/TestFromBytes_ErrStringLength.golden differ