Skip to content

Commit 8776cce

Browse files
fix: out-of-bounds-read in parseItemOrInnerList
1 parent cee7313 commit 8776cce

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

dictionary_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ func TestUnmarshalDictionary(t *testing.T) {
9999
valid bool
100100
}{
101101
{[]string{"a=?0, b, c; foo=bar"}, d1, false},
102+
{[]string{"a="}, nil, false},
102103
{[]string{"a=?0, b", "c; foo=bar"}, d1, false},
103104
{[]string{""}, NewDictionary(), false},
104105
{[]string{"é"}, nil, true},

list.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ func parseList(s *scanner) (List, error) {
8787
// parseItemOrInnerList parses as defined in
8888
// https://httpwg.org/http-extensions/draft-ietf-httpbis-header-structure.html#parse-item-or-list.
8989
func parseItemOrInnerList(s *scanner) (Member, error) {
90+
if s.eof() {
91+
return nil, &UnmarshalError{s.off, ErrInvalidInnerListFormat}
92+
}
9093
if s.data[s.off] == '(' {
9194
return parseInnerList(s)
9295
}

0 commit comments

Comments
 (0)