Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDon Zickus <dzickus@redhat.com>2008-08-14 19:35:42 +0400
committerJunio C Hamano <gitster@pobox.com>2008-08-19 09:05:02 +0400
commit289796dd29dd656734cfd59b657deb943a71cf6a (patch)
tree7ff6e57895095b4ef499bd18c8d665e43a457103 /builtin-mailinfo.c
parentdba9194a49452b5f093b96872e19c91b50e526aa (diff)
mailinfo: re-fix MIME multipart boundary parsing
Recent changes to is_multipart_boundary() caused git-mailinfo to segfault. The reason was after handling the end of the boundary the code tried to look for another boundary. Because the boundary list was empty, dereferencing the pointer to the top of the boundary caused the program to go boom. The fix is to check to see if the list is empty and if so go on its merry way instead of looking for another boundary. I also fixed a couple of increments and decrements that didn't look correct relating to content_top. The boundary test case was updated to catch future problems like this again. Signed-off-by: Don Zickus <dzickus@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-mailinfo.c')
-rw-r--r--builtin-mailinfo.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index 3577382d70..26d3e5d7af 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -175,7 +175,7 @@ static void handle_content_type(struct strbuf *line)
message_type = TYPE_OTHER;
if (slurp_attr(line->buf, "boundary=", boundary)) {
strbuf_insert(boundary, 0, "--", 2);
- if (content_top++ >= &content[MAX_BOUNDARIES]) {
+ if (++content_top > &content[MAX_BOUNDARIES]) {
fprintf(stderr, "Too many boundaries to handle\n");
exit(1);
}
@@ -603,7 +603,7 @@ static void handle_filter(struct strbuf *line);
static int find_boundary(void)
{
while (!strbuf_getline(&line, fin, '\n')) {
- if (is_multipart_boundary(&line))
+ if (*content_top && is_multipart_boundary(&line))
return 1;
}
return 0;
@@ -626,7 +626,7 @@ again:
/* technically won't happen as is_multipart_boundary()
will fail first. But just in case..
*/
- if (content_top-- < content) {
+ if (--content_top < content) {
fprintf(stderr, "Detected mismatched boundaries, "
"can't recover\n");
exit(1);