]> diplodocus.org Git - nmh/commitdiff
Have m_getfld() pass back indication of missing blank line.
authorDavid Levine <levinedl@acm.org>
Fri, 21 Oct 2016 17:22:22 +0000 (13:22 -0400)
committerDavid Levine <levinedl@acm.org>
Fri, 21 Oct 2016 17:22:22 +0000 (13:22 -0400)
This is part one of a two part fix to the MIME parser to
read binary content.  It should have no effect.

Also added start/finish test calls to test-header.

sbr/m_getfld.c
test/bad-input/test-header

index 1a1411e..6d5f04f 100644 (file)
@@ -581,6 +581,9 @@ m_getfld (m_getfld_state_t *gstate, char name[NAMESZ], char *buf, int *bufsz,
                memcpy (buf, name, n - 1);
                buf[n - 1] = '\n';
                buf[n] = '\0';
                memcpy (buf, name, n - 1);
                buf[n - 1] = '\n';
                buf[n] = '\0';
+                /* Indicate this wasn't a header field using a character
+                   that can't appear in a header field. */
+                name[0] = ':';
                /* The last character read was '\n'.  s->bytes_read
                   (and n) include that, but it was not put into the
                   name array in the for loop above.  So subtract 1. */
                /* The last character read was '\n'.  s->bytes_read
                   (and n) include that, but it was not put into the
                   name array in the for loop above.  So subtract 1. */
index eeacc83..ef7b399 100755 (executable)
@@ -34,6 +34,7 @@ I am a stupid spammer.
 EOF
 
 # check scan
 EOF
 
 # check scan
+start_test scan
 cat >"$expected" <<EOF
   11  12/18 foo@example.edu    test<<This is a multi-part message in MIME format
 EOF
 cat >"$expected" <<EOF
   11  12/18 foo@example.edu    test<<This is a multi-part message in MIME format
 EOF
@@ -41,6 +42,7 @@ run_prog scan -width 80 last > "$actual" 2>&1
 check "$expected" "$actual" : scan with bogus header field
 
 # check show (mhl)
 check "$expected" "$actual" : scan with bogus header field
 
 # check show (mhl)
+start_test show
 cat >"$expected" <<EOF
 (Message inbox:11)
 
 cat >"$expected" <<EOF
 (Message inbox:11)
 
@@ -58,6 +60,7 @@ run_prog show last > "$actual" 2>&1
 check "$expected" "$actual" : "show (mhl) with bogus header field"
 
 # check mhshow
 check "$expected" "$actual" : "show (mhl) with bogus header field"
 
 # check mhshow
+start_test mhshow
 cat >"$expected" <<EOF
 [ Message inbox:11 ]
 Date:    Sun, 18 Dec 2005 00:52:39 +0100
 cat >"$expected" <<EOF
 [ Message inbox:11 ]
 Date:    Sun, 18 Dec 2005 00:52:39 +0100
@@ -76,6 +79,7 @@ run_prog mhshow last > "$actual" 2>&1
 check "$expected" "$actual" : mhshow with bogus header field
 
 # check m_getfld() handling of empty header field
 check "$expected" "$actual" : mhshow with bogus header field
 
 # check m_getfld() handling of empty header field
+start_test 'm_getfld() handling of empty header field'
 msgfile="$MH_TEST_DIR/Mail/inbox/12"
 printf 'Date: Sat, 12 Jan 2013 09:07:01 -0600\nReceived:' >"$msgfile"
 cat >"$expected" <<EOF
 msgfile="$MH_TEST_DIR/Mail/inbox/12"
 printf 'Date: Sat, 12 Jan 2013 09:07:01 -0600\nReceived:' >"$msgfile"
 cat >"$expected" <<EOF
@@ -91,6 +95,7 @@ check "$expected" "$actual" : m_getfld, empty header output
 check "$expected_err" "$actual_err" : m_getfld, empty header error
 
 # check m_getfld() handling of excessively long header field name
 check "$expected_err" "$actual_err" : m_getfld, empty header error
 
 # check m_getfld() handling of excessively long header field name
+start_test 'm_getfld() handling of excessively long header field name'
 msgfile="$MH_TEST_DIR/Mail/inbox/13"
 cat >"$msgfile" <<EOF
 Date: Tue, 15 Jan 2013 21:13:12 -0600
 msgfile="$MH_TEST_DIR/Mail/inbox/13"
 cat >"$msgfile" <<EOF
 Date: Tue, 15 Jan 2013 21:13:12 -0600
@@ -118,6 +123,7 @@ verify_string_in_file '??Format error (message 13) in component 2' "$actual_err"
 rm -f "$actual_err"
 
 # check m_getfld() handling of long header field name without a colon
 rm -f "$actual_err"
 
 # check m_getfld() handling of long header field name without a colon
+start_test 'm_getfld() handling of long header field name without a colon'
 msgfile="$MH_TEST_DIR/Mail/inbox/14"
 cat >"$msgfile" <<EOF
 Date: Thu, 17 Jan 2013 19:33:46 -0600
 msgfile="$MH_TEST_DIR/Mail/inbox/14"
 cat >"$msgfile" <<EOF
 Date: Thu, 17 Jan 2013 19:33:46 -0600
@@ -140,4 +146,5 @@ check "$expected" "$actual" : m_getfld with long header, no colon output
 check "$expected_err" "$actual_err" : m_getfld with long header, no colon error
 
 
 check "$expected_err" "$actual_err" : m_getfld with long header, no colon error
 
 
+finish_test
 exit $failed
 exit $failed