@@ -1392,16 +1392,31 @@ static void test_parse_bogus_charset_params(void)
1392
1392
}
1393
1393
1394
1394
/*
1395
- * Verifies that message_parse_received_date() does not read
1396
- * uninitialized data in the second call to message_parse_string()
1395
+ * Verifies that message_parse_received_date() does not
1396
+ * read any but the first Received header for invalid values.
1397
1397
*/
1398
1398
static void test_parse_received_semicolon (void )
1399
1399
{
1400
- static const char msg [] = "Received: abc;\r\n\r\nd" ;
1400
+ static const char msg_emptydate [] =
1401
+ "Received: abc;\r\n"
1402
+ "Received: from foo by bar; Fri, 29 Oct 2010 13:05:01 +1100\r\n"
1403
+ "\r\n" ;
1401
1404
struct body body ;
1402
1405
memset (& body , 0x45 , sizeof (body ));
1403
- CU_ASSERT_EQUAL (message_parse_mapped (msg , sizeof (msg )- 1 , & body , NULL ), 0 );
1404
- CU_ASSERT_PTR_NULL (body .received_date );
1406
+ CU_ASSERT_EQUAL (message_parse_mapped (msg_emptydate ,
1407
+ sizeof (msg_emptydate )- 1 , & body , NULL ), 0 );
1408
+ CU_ASSERT_STRING_EQUAL (body .received_date , "" );
1405
1409
message_free_body (& body );
1410
+
1411
+ static const char msg_nodate [] =
1412
+ "Received: abc\r\n"
1413
+ "Received: from foo by bar; Fri, 29 Oct 2010 13:05:01 +1100\r\n"
1414
+ "\r\n" ;
1415
+ memset (& body , 0x45 , sizeof (body ));
1416
+ CU_ASSERT_EQUAL (message_parse_mapped (msg_nodate ,
1417
+ sizeof (msg_nodate )- 1 , & body , NULL ), 0 );
1418
+ CU_ASSERT_STRING_EQUAL (body .received_date , "abc" );
1419
+ message_free_body (& body );
1420
+
1406
1421
}
1407
1422
/* vim: set ft=c: */
0 commit comments