Skip to content

Commit 8559425

Browse files
pcloudsgitster
authored andcommitted
parse_tag_buffer(): do not prefixcmp() out of range
There is a check (size < 64) at the beginning of the function, but that only covers object+type lines. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 24231e0 commit 8559425

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tag.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
9797
item->tagged = NULL;
9898
}
9999

100-
if (prefixcmp(bufptr, "tag "))
100+
if (bufptr + 4 < tail && !prefixcmp(bufptr, "tag "))
101+
; /* good */
102+
else
101103
return -1;
102104
bufptr += 4;
103105
nl = memchr(bufptr, '\n', tail - bufptr);
@@ -106,7 +108,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
106108
item->tag = xmemdupz(bufptr, nl - bufptr);
107109
bufptr = nl + 1;
108110

109-
if (!prefixcmp(bufptr, "tagger "))
111+
if (bufptr + 7 < tail && !prefixcmp(bufptr, "tagger "))
110112
item->date = parse_tag_date(bufptr, tail);
111113
else
112114
item->date = 0;

0 commit comments

Comments
 (0)