app-layer-smtp: fix Test14.

Was running one byte past end of buffer.
Declare Unit Test 14's data as static.
pull/1195/head
Tom DeCanio 11 years ago committed by Victor Julien
parent 260872ccd9
commit 6467a5d563

@ -3905,7 +3905,7 @@ int SMTPParserTest14(void)
int r = 0; int r = 0;
/* 220 mx.google.com ESMTP d15sm986283wfl.6<CR><LF> */ /* 220 mx.google.com ESMTP d15sm986283wfl.6<CR><LF> */
uint8_t welcome_reply[] = { static uint8_t welcome_reply[] = {
0x32, 0x32, 0x30, 0x20, 0x6d, 0x78, 0x2e, 0x67, 0x32, 0x32, 0x30, 0x20, 0x6d, 0x78, 0x2e, 0x67,
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x63, 0x6f,
0x6d, 0x20, 0x45, 0x53, 0x4d, 0x54, 0x50, 0x20, 0x6d, 0x20, 0x45, 0x53, 0x4d, 0x54, 0x50, 0x20,
@ -3913,21 +3913,21 @@ int SMTPParserTest14(void)
0x32, 0x38, 0x33, 0x77, 0x66, 0x6c, 0x2e, 0x36, 0x32, 0x38, 0x33, 0x77, 0x66, 0x6c, 0x2e, 0x36,
0x0d, 0x0a 0x0d, 0x0a
}; };
uint32_t welcome_reply_len = sizeof(welcome_reply); static uint32_t welcome_reply_len = sizeof(welcome_reply);
/* EHLO boo.com<CR><LF> */ /* EHLO boo.com<CR><LF> */
uint8_t request1[] = { static uint8_t request1[] = {
0x45, 0x48, 0x4c, 0x4f, 0x20, 0x62, 0x6f, 0x6f, 0x45, 0x48, 0x4c, 0x4f, 0x20, 0x62, 0x6f, 0x6f,
0x2e, 0x63, 0x6f, 0x6d, 0x0d, 0x0a 0x2e, 0x63, 0x6f, 0x6d, 0x0d, 0x0a
}; };
uint32_t request1_len = sizeof(request1); static uint32_t request1_len = sizeof(request1);
/* 250-mx.google.com at your service, [117.198.115.50]<CR><LF> /* 250-mx.google.com at your service, [117.198.115.50]<CR><LF>
* 250-SIZE 35882577<CR><LF> * 250-SIZE 35882577<CR><LF>
* 250-8BITMIME<CR><LF> * 250-8BITMIME<CR><LF>
* 250-STARTTLS<CR><LF> * 250-STARTTLS<CR><LF>
* 250 ENHANCEDSTATUSCODES<CR><LF> * 250 ENHANCEDSTATUSCODES<CR><LF>
*/ */
uint8_t reply1[] = { static uint8_t reply1[] = {
0x32, 0x35, 0x30, 0x2d, 0x70, 0x6f, 0x6f, 0x6e, 0x32, 0x35, 0x30, 0x2d, 0x70, 0x6f, 0x6f, 0x6e,
0x61, 0x5f, 0x73, 0x6c, 0x61, 0x63, 0x6b, 0x5f, 0x61, 0x5f, 0x73, 0x6c, 0x61, 0x63, 0x6b, 0x5f,
0x76, 0x6d, 0x31, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x76, 0x6d, 0x31, 0x2e, 0x6c, 0x6f, 0x63, 0x61,
@ -3946,56 +3946,56 @@ int SMTPParserTest14(void)
0x54, 0x4d, 0x49, 0x4d, 0x45, 0x0d, 0x0a, 0x32, 0x54, 0x4d, 0x49, 0x4d, 0x45, 0x0d, 0x0a, 0x32,
0x35, 0x30, 0x20, 0x44, 0x53, 0x4e, 0x0d, 0x0a 0x35, 0x30, 0x20, 0x44, 0x53, 0x4e, 0x0d, 0x0a
}; };
uint32_t reply1_len = sizeof(reply1); static uint32_t reply1_len = sizeof(reply1);
/* MAIL FROM:asdff@asdf.com<CR><LF> */ /* MAIL FROM:asdff@asdf.com<CR><LF> */
uint8_t request2[] = { static uint8_t request2[] = {
0x4d, 0x41, 0x49, 0x4c, 0x20, 0x46, 0x52, 0x4f, 0x4d, 0x41, 0x49, 0x4c, 0x20, 0x46, 0x52, 0x4f,
0x4d, 0x3a, 0x61, 0x73, 0x64, 0x66, 0x66, 0x40, 0x4d, 0x3a, 0x61, 0x73, 0x64, 0x66, 0x66, 0x40,
0x61, 0x73, 0x64, 0x66, 0x2e, 0x63, 0x6f, 0x6d, 0x61, 0x73, 0x64, 0x66, 0x2e, 0x63, 0x6f, 0x6d,
0x0d, 0x0a 0x0d, 0x0a
}; };
uint32_t request2_len = sizeof(request2); static uint32_t request2_len = sizeof(request2);
/* 250 2.1.0 Ok<CR><LF> */ /* 250 2.1.0 Ok<CR><LF> */
uint8_t reply2[] = { static uint8_t reply2[] = {
0x32, 0x35, 0x30, 0x20, 0x32, 0x2e, 0x31, 0x2e, 0x32, 0x35, 0x30, 0x20, 0x32, 0x2e, 0x31, 0x2e,
0x30, 0x20, 0x4f, 0x6b, 0x0d, 0x0a 0x30, 0x20, 0x4f, 0x6b, 0x0d, 0x0a
}; };
uint32_t reply2_len = sizeof(reply2); static uint32_t reply2_len = sizeof(reply2);
/* RCPT TO:bimbs@gmail.com<CR><LF> */ /* RCPT TO:bimbs@gmail.com<CR><LF> */
uint8_t request3[] = { static uint8_t request3[] = {
0x52, 0x43, 0x50, 0x54, 0x20, 0x54, 0x4f, 0x3a, 0x52, 0x43, 0x50, 0x54, 0x20, 0x54, 0x4f, 0x3a,
0x62, 0x69, 0x6d, 0x62, 0x73, 0x40, 0x67, 0x6d, 0x62, 0x69, 0x6d, 0x62, 0x73, 0x40, 0x67, 0x6d,
0x61, 0x69, 0x6c, 0x2e, 0x63, 0x6f, 0x6d, 0x0d, 0x61, 0x69, 0x6c, 0x2e, 0x63, 0x6f, 0x6d, 0x0d,
0x0a 0x0a
}; };
uint32_t request3_len = sizeof(request3); static uint32_t request3_len = sizeof(request3);
/* 250 2.1.5 Ok<CR><LF> */ /* 250 2.1.5 Ok<CR><LF> */
uint8_t reply3[] = { static uint8_t reply3[] = {
0x32, 0x35, 0x30, 0x20, 0x32, 0x2e, 0x31, 0x2e, 0x32, 0x35, 0x30, 0x20, 0x32, 0x2e, 0x31, 0x2e,
0x35, 0x20, 0x4f, 0x6b, 0x0d, 0x0a 0x35, 0x20, 0x4f, 0x6b, 0x0d, 0x0a
}; };
uint32_t reply3_len = sizeof(reply3); static uint32_t reply3_len = sizeof(reply3);
/* DATA<CR><LF> */ /* DATA<CR><LF> */
uint8_t request4[] = { static uint8_t request4[] = {
0x44, 0x41, 0x54, 0x41, 0x0d, 0x0a 0x44, 0x41, 0x54, 0x41, 0x0d, 0x0a
}; };
uint32_t request4_len = sizeof(request4); static uint32_t request4_len = sizeof(request4);
/* 354 End data with <CR><LF>.<CR><LF>|<CR><LF>| */ /* 354 End data with <CR><LF>.<CR><LF>|<CR><LF>| */
uint8_t reply4[] = { static uint8_t reply4[] = {
0x33, 0x35, 0x34, 0x20, 0x45, 0x6e, 0x64, 0x20, 0x33, 0x35, 0x34, 0x20, 0x45, 0x6e, 0x64, 0x20,
0x64, 0x61, 0x74, 0x61, 0x20, 0x77, 0x69, 0x74, 0x64, 0x61, 0x74, 0x61, 0x20, 0x77, 0x69, 0x74,
0x68, 0x20, 0x3c, 0x43, 0x52, 0x3e, 0x3c, 0x4c, 0x68, 0x20, 0x3c, 0x43, 0x52, 0x3e, 0x3c, 0x4c,
0x46, 0x3e, 0x2e, 0x3c, 0x43, 0x52, 0x3e, 0x3c, 0x46, 0x3e, 0x2e, 0x3c, 0x43, 0x52, 0x3e, 0x3c,
0x4c, 0x46, 0x3e, 0x0d, 0x0a 0x4c, 0x46, 0x3e, 0x0d, 0x0a
}; };
uint32_t reply4_len = sizeof(reply4); static uint32_t reply4_len = sizeof(reply4);
/* MIME_MSG */ /* MIME_MSG */
uint64_t filesize = 133; static uint64_t filesize = 133;
uint8_t request4_msg[] = { static uint8_t request4_msg[] = {
0x4D, 0x49, 0x4D, 0x45, 0x2D, 0x56, 0x65, 0x72, 0x4D, 0x49, 0x4D, 0x45, 0x2D, 0x56, 0x65, 0x72,
0x73, 0x69, 0x6F, 0x6E, 0x3A, 0x20, 0x31, 0x2E, 0x73, 0x69, 0x6F, 0x6E, 0x3A, 0x20, 0x31, 0x2E,
0x30, 0x0D, 0x0A, 0x43, 0x6F, 0x6E, 0x74, 0x65, 0x30, 0x0D, 0x0A, 0x43, 0x6F, 0x6E, 0x74, 0x65,
@ -4038,34 +4038,34 @@ int SMTPParserTest14(void)
0x6A, 0x6B, 0x7A, 0x4C, 0x6A, 0x59, 0x34, 0x4C, 0x6A, 0x6B, 0x7A, 0x4C, 0x6A, 0x59, 0x34, 0x4C,
0x6A, 0x5A, 0x63, 0x65, 0x67, 0x41, 0x41, 0x4F, 0x6A, 0x5A, 0x63, 0x65, 0x67, 0x41, 0x41, 0x4F,
0x41, 0x3D, 0x3D, 0x0D,0x0A }; 0x41, 0x3D, 0x3D, 0x0D,0x0A };
uint32_t request4_msg_len = sizeof(request4_msg); static uint32_t request4_msg_len = sizeof(request4_msg);
/* DATA COMPLETED */ /* DATA COMPLETED */
uint8_t request4_end[] = { static uint8_t request4_end[] = {
0x0d, 0x0a, 0x2e, 0x0d, 0x0a 0x0d, 0x0a, 0x2e, 0x0d, 0x0a
}; };
uint32_t request4_end_len = sizeof(request4_end); static uint32_t request4_end_len = sizeof(request4_end);
/* 250 2.0.0 Ok: queued as 6A1AF20BF2<CR><LF> */ /* 250 2.0.0 Ok: queued as 6A1AF20BF2<CR><LF> */
uint8_t reply4_end[] = { static uint8_t reply4_end[] = {
0x32, 0x35, 0x30, 0x20, 0x32, 0x2e, 0x30, 0x2e, 0x32, 0x35, 0x30, 0x20, 0x32, 0x2e, 0x30, 0x2e,
0x30, 0x20, 0x4f, 0x6b, 0x3a, 0x20, 0x71, 0x75, 0x30, 0x20, 0x4f, 0x6b, 0x3a, 0x20, 0x71, 0x75,
0x65, 0x75, 0x65, 0x64, 0x20, 0x61, 0x73, 0x20, 0x65, 0x75, 0x65, 0x64, 0x20, 0x61, 0x73, 0x20,
0x36, 0x41, 0x31, 0x41, 0x46, 0x32, 0x30, 0x42, 0x36, 0x41, 0x31, 0x41, 0x46, 0x32, 0x30, 0x42,
0x46, 0x32, 0x0d, 0x0a 0x46, 0x32, 0x0d, 0x0a
}; };
uint32_t reply4_end_len = sizeof(reply4_end); static uint32_t reply4_end_len = sizeof(reply4_end);
/* QUIT<CR><LF> */ /* QUIT<CR><LF> */
uint8_t request5[] = { static uint8_t request5[] = {
0x51, 0x55, 0x49, 0x54, 0x0d, 0x0a 0x51, 0x55, 0x49, 0x54, 0x0d, 0x0a
}; };
uint32_t request5_len = sizeof(request5); static uint32_t request5_len = sizeof(request5);
/* 221 2.0.0 Bye<CR><LF> */ /* 221 2.0.0 Bye<CR><LF> */
uint8_t reply5[] = { static uint8_t reply5[] = {
0x32, 0x32, 0x31, 0x20, 0x32, 0x2e, 0x30, 0x2e, 0x32, 0x32, 0x31, 0x20, 0x32, 0x2e, 0x30, 0x2e,
0x30, 0x20, 0x42, 0x79, 0x65, 0x0d, 0x0a 0x30, 0x20, 0x42, 0x79, 0x65, 0x0d, 0x0a
}; };
uint32_t reply5_len = sizeof(reply5); static uint32_t reply5_len = sizeof(reply5);
TcpSession ssn; TcpSession ssn;
AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc();
@ -4312,7 +4312,8 @@ int SMTPParserTest14(void)
printf("smtp-mime file size %lu is incorrect", file->size); printf("smtp-mime file size %lu is incorrect", file->size);
goto end; goto end;
} }
uint8_t org_binary[] = {0x4D, 0x5A, 0x00, 0x00, 0x50, 0x45, 0x00, 0x00, static uint8_t org_binary[] = {
0x4D, 0x5A, 0x00, 0x00, 0x50, 0x45, 0x00, 0x00,
0x4C, 0x01, 0x01, 0x00, 0x6A, 0x2A, 0x58, 0xC3, 0x4C, 0x01, 0x01, 0x00, 0x6A, 0x2A, 0x58, 0xC3,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x03, 0x01, 0x0B, 0x01, 0x08, 0x00, 0x04, 0x00, 0x03, 0x01, 0x0B, 0x01, 0x08, 0x00,
@ -4330,7 +4331,7 @@ int SMTPParserTest14(void)
0x2E, 0x39, 0x33, 0x2E, 0x36, 0x38, 0x2E, 0x36, 0x2E, 0x39, 0x33, 0x2E, 0x36, 0x38, 0x2E, 0x36,
0x5C, 0x7A, 0x00, 0x00, 0x38,}; 0x5C, 0x7A, 0x00, 0x00, 0x38,};
uint64_t z; uint64_t z;
for (z=0; z <= filesize; z++){ for (z=0; z < filesize; z++){
if(org_binary[z] != file->chunks_head->data[z]){ if(org_binary[z] != file->chunks_head->data[z]){
printf("smtp-mime file data incorrect\n"); printf("smtp-mime file data incorrect\n");
goto end; goto end;

Loading…
Cancel
Save