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 <julian@quantumfyre.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Julian Phillips committed Jul 16, 2011 at 19:23 UTC 6e8e67f3071ecdc139f6a77f90afee50b5ec1664
1 file changed +2
remote-curl.c
+2
@@ -227,6 +227,8 @@ static struct ref *parse_info_refs(struct discovery *heads)
227 if (data[i] == '\t')
228 mid = &data[i];
229 if (data[i] == '\n') {
230 + if (mid - start != 40)
231 + die("%sinfo/refs not valid: is this a git repository?", url);
232 data[i] = 0;
233 ref_name = mid + 1;
234 ref = xmalloc(sizeof(struct ref) +