summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dba9194)
raw | patch | inline | side by side (parent: dba9194)
author | Don Zickus <dzickus@redhat.com> | |
Thu, 14 Aug 2008 15:35:42 +0000 (11:35 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 19 Aug 2008 05:05:02 +0000 (22:05 -0700) |
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>
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>
builtin-mailinfo.c | patch | blob | history | |
t/t5100/sample.mbox | patch | blob | history |
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index 3577382d7039784e8a0c5ef9ce3d765409abb2d8..26d3e5d7af1c9d0f4e0e00143ed157f81ee595d0 100644 (file)
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
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);
}
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;
/* 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);
diff --git a/t/t5100/sample.mbox b/t/t5100/sample.mbox
index d7ca79b1fc1c5842cb0ebd95cc7055459f0391a0..4bf7947b418963e9b15e393fc738e515b3d2141d 100644 (file)
--- a/t/t5100/sample.mbox
+++ b/t/t5100/sample.mbox
1.6.0.rc2
--=-=-=--
+