summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2ed0288)
raw | patch | inline | side by side (parent: 2ed0288)
author | Junio C Hamano <junkio@cox.net> | |
Tue, 15 Nov 2005 01:15:07 +0000 (17:15 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Tue, 15 Nov 2005 01:15:07 +0000 (17:15 -0800) |
The comparison to find "Binary files " string was looking at a
wrong place when offset != 0.
Also, we may have the full 40-byte textual sha1 on the index
line; two off-by-one errors prevented it.
Signed-off-by: Junio C Hamano <junkio@cox.net>
wrong place when offset != 0.
Also, we may have the full 40-byte textual sha1 on the index
line; two off-by-one errors prevented it.
Signed-off-by: Junio C Hamano <junkio@cox.net>
apply.c | patch | blob | history |
index 34181188b890df19c8a5c96a1c1eec21db4805c1..590adc6afafa98e389dcafc2f8c432db09412d4e 100644 (file)
--- a/apply.c
+++ b/apply.c
int len;
ptr = strchr(line, '.');
- if (!ptr || ptr[1] != '.' || 40 <= ptr - line)
+ if (!ptr || ptr[1] != '.' || 40 < ptr - line)
return 0;
len = ptr - line;
memcpy(patch->old_sha1_prefix, line, len);
ptr = eol;
len = ptr - line;
- if (40 <= len)
+ if (40 < len)
return 0;
memcpy(patch->new_sha1_prefix, line, len);
patch->new_sha1_prefix[len] = 0;
static const char binhdr[] = "Binary files ";
if (sizeof(binhdr) - 1 < size - offset - hdrsize &&
- !memcmp(binhdr, buffer + hdrsize, sizeof(binhdr)-1))
+ !memcmp(binhdr, buffer + hdrsize + offset,
+ sizeof(binhdr)-1))
patch->is_binary = 1;
if (patch->is_binary && !apply && !check)