X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=apply.c;h=590adc6afafa98e389dcafc2f8c432db09412d4e;hb=f8348be3be8493a62110a09ab0343213990b416b;hp=472bcdc369aec31d3c72d8b4bca74feca2798281;hpb=cb93c19365760d939f05d9a3c2ef4499f0d5ce16;p=git.git diff --git a/apply.c b/apply.c index 472bcdc3..590adc6a 100644 --- a/apply.c +++ b/apply.c @@ -27,7 +27,7 @@ static int no_add = 0; static int show_index_info = 0; static int line_termination = '\n'; static const char apply_usage[] = -"git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--apply] [--index-info] [-z] ..."; +"git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--apply] [--no-add] [--index-info] [-z] ..."; /* * For "diff-stat" like behaviour, we keep track of the biggest change @@ -370,7 +370,7 @@ static int gitdiff_index(const char *line, struct patch *patch) 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); @@ -384,7 +384,7 @@ static int gitdiff_index(const char *line, struct patch *patch) 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; @@ -895,7 +895,8 @@ static int parse_chunk(char *buffer, unsigned long size, struct patch *patch) 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)