From: Junio C Hamano Date: Wed, 25 Jun 2014 18:48:23 +0000 (-0700) Subject: Merge branch 'rs/mailinfo-header-cmp' into maint X-Git-Tag: v2.0.1~11 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/ed5d0d2105c84ec40dd7526c9cd20e4587c62987?hp=-c Merge branch 'rs/mailinfo-header-cmp' into maint "git mailinfo" used to read beyond the end of header string while parsing an incoming e-mail message to extract the patch. * rs/mailinfo-header-cmp: mailinfo: use strcmp() for string comparison --- ed5d0d2105c84ec40dd7526c9cd20e4587c62987 diff --combined builtin/mailinfo.c index 2c3cd8eab7,6b44156264..cf11c8d607 --- a/builtin/mailinfo.c +++ b/builtin/mailinfo.c @@@ -328,13 -328,13 +328,13 @@@ static int check_header(const struct st } /* for inbody stuff */ - if (!prefixcmp(line->buf, ">From") && isspace(line->buf[5])) { + if (starts_with(line->buf, ">From") && isspace(line->buf[5])) { ret = 1; /* Should this return 0? */ goto check_header_out; } - if (!prefixcmp(line->buf, "[PATCH]") && isspace(line->buf[7])) { + if (starts_with(line->buf, "[PATCH]") && isspace(line->buf[7])) { for (i = 0; header[i]; i++) { - if (!memcmp("Subject", header[i], 7)) { + if (!strcmp("Subject", header[i])) { handle_header(&hdr_data[i], line); ret = 1; goto check_header_out; @@@ -361,7 -361,7 +361,7 @@@ static int is_rfc2822_header(const stru char *cp = line->buf; /* Count mbox From headers as headers */ - if (!prefixcmp(cp, "From ") || !prefixcmp(cp, ">From ")) + if (starts_with(cp, "From ") || starts_with(cp, ">From ")) return 1; while ((ch = *cp++)) { @@@ -671,11 -671,11 +671,11 @@@ static inline int patchbreak(const stru size_t i; /* Beginning of a "diff -" header? */ - if (!prefixcmp(line->buf, "diff -")) + if (starts_with(line->buf, "diff -")) return 1; /* CVS "Index: " line? */ - if (!prefixcmp(line->buf, "Index: ")) + if (starts_with(line->buf, "Index: ")) return 1; /* @@@ -685,7 -685,7 +685,7 @@@ if (line->len < 4) return 0; - if (!prefixcmp(line->buf, "---")) { + if (starts_with(line->buf, "---")) { /* space followed by a filename? */ if (line->buf[3] == ' ' && !isspace(line->buf[4])) return 1; @@@ -929,13 -929,13 +929,13 @@@ static void handle_info(void else continue; - if (!memcmp(header[i], "Subject", 7)) { + if (!strcmp(header[i], "Subject")) { if (!keep_subject) { cleanup_subject(hdr); cleanup_space(hdr); } output_header_lines(fout, "Subject", hdr); - } else if (!memcmp(header[i], "From", 4)) { + } else if (!strcmp(header[i], "From")) { cleanup_space(hdr); handle_from(hdr); fprintf(fout, "Author: %s\n", name.buf); @@@ -986,7 -986,7 +986,7 @@@ static int mailinfo(FILE *in, FILE *out static int git_mailinfo_config(const char *var, const char *value, void *unused) { - if (prefixcmp(var, "mailinfo.")) + if (!starts_with(var, "mailinfo.")) return git_default_config(var, value, unused); if (!strcmp(var, "mailinfo.scissors")) { use_scissors = git_config_bool(var, value); @@@ -1020,7 -1020,7 +1020,7 @@@ int cmd_mailinfo(int argc, const char * metainfo_charset = def_charset; else if (!strcmp(argv[1], "-n")) metainfo_charset = NULL; - else if (!prefixcmp(argv[1], "--encoding=")) + else if (starts_with(argv[1], "--encoding=")) metainfo_charset = argv[1] + 11; else if (!strcmp(argv[1], "--scissors")) use_scissors = 1;