From 5a17b54ad5543ddca60a493c613801279cc98a34 Mon Sep 17 00:00:00 2001 From: Junio C Hamano <junkio@cox.net> Date: Tue, 9 Jan 2007 02:52:31 -0800 Subject: [PATCH 1/2] Do not ignore a detected patchfile brokenness. find_header() function is used to read and parse the patchfile and it detects errors in the patch, but one place ignored the error and went ahead, which was quite bad. Noticed by Jeff Garzik. Signed-off-by: Junio C Hamano <junkio@cox.net> --- builtin-apply.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin-apply.c b/builtin-apply.c index 61f047fd453..6a06be3025d 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -812,7 +812,7 @@ static int find_header(char *line, unsigned long size, int *hdrsize, struct patc struct fragment dummy; if (parse_fragment_header(line, len, &dummy) < 0) continue; - error("patch fragment without header at line %d: %.*s", linenr, (int)len-1, line); + return error("patch fragment without header at line %d: %.*s", linenr, (int)len-1, line); } if (size < len + 6) From 6534141151f7fd4334f62827d9234acf3974ca4d Mon Sep 17 00:00:00 2001 From: Junio C Hamano <junkio@cox.net> Date: Tue, 9 Jan 2007 11:50:53 -0800 Subject: [PATCH 2/2] Fix "Do not ignore a detected patchfile brokenness." Returning negative value from there does not stop the caller from using the earlier part. Noticed by Linus. Signed-off-by: Junio C Hamano <junkio@cox.net> --- builtin-apply.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin-apply.c b/builtin-apply.c index 6a06be3025d..721d011bd05 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -812,7 +812,8 @@ static int find_header(char *line, unsigned long size, int *hdrsize, struct patc struct fragment dummy; if (parse_fragment_header(line, len, &dummy) < 0) continue; - return error("patch fragment without header at line %d: %.*s", linenr, (int)len-1, line); + die("patch fragment without header at line %d: %.*s", + linenr, (int)len-1, line); } if (size < len + 6)