smb: allow dynamic length fields of exact length (#323)

This commit is contained in:
Elliot Cubit 2021-07-26 15:57:24 -04:00 committed by GitHub
parent 6a8e4f5abe
commit a1d5e930ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -441,7 +441,7 @@ func unmarshal(buf []byte, v interface{}, meta *Metadata) (interface{}, error) {
o = int(meta.CurrOffset)
}
// Prevent searching past the end of the buffer for variable data
if o+l >= len(meta.ParentBuf) {
if o+l > len(meta.ParentBuf) {
return nil, errors.New(fmt.Sprintf("field '%s' wants %d bytes but only %d bytes remain.", meta.CurrField, l, len(meta.ParentBuf)-o))
}
// Variable length data is relative to parent/outer struct. Reset reader to point to beginning of data