Skip to content

Commit 6e8e67f

Browse files
qurgitster
authored andcommitted
remote-curl: Add a format check to parsing of info/refs
When parsing info/refs, no checks were applied that the file was in the requried format. Since the file is read from a remote webserver, this isn't guarenteed to be true. Add a check that the file at least only contains lines that consist of 40 characters followed by a tab and then the ref name. Signed-off-by: Julian Phillips <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8b59007 commit 6e8e67f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

remote-curl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ static struct ref *parse_info_refs(struct discovery *heads)
227227
if (data[i] == '\t')
228228
mid = &data[i];
229229
if (data[i] == '\n') {
230+
if (mid - start != 40)
231+
die("%sinfo/refs not valid: is this a git repository?", url);
230232
data[i] = 0;
231233
ref_name = mid + 1;
232234
ref = xmalloc(sizeof(struct ref) +

0 commit comments

Comments
 (0)