From 87599bc78d2569100358a3090ba7c34dd84daf64 Mon Sep 17 00:00:00 2001 From: Anoop Saldanha Date: Mon, 21 Nov 2011 18:28:14 +0530 Subject: [PATCH] minor changes in smtp parser decoder wrt direction check loop + add missing ifdef unittests --- src/app-layer-smtp.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/app-layer-smtp.c b/src/app-layer-smtp.c index 88cd738c61..b9681ecace 100644 --- a/src/app-layer-smtp.c +++ b/src/app-layer-smtp.c @@ -626,14 +626,16 @@ static int SMTPParse(int direction, Flow *f, SMTPState *state, state->input_len = input_len; state->direction = direction; - while (SMTPGetLine(state) >= 0) { - /* toserver */ - if (direction == 0) { + /* toserver */ + if (direction == 0) { + while (SMTPGetLine(state) >= 0) { if (SMTPProcessRequest(state, f, pstate) == -1) return -1; + } - /* toclient */ - } else { + /* toclient */ + } else { + while (SMTPGetLine(state) >= 0) { if (SMTPProcessReply(state, f, pstate) == -1) return -1; } @@ -778,6 +780,8 @@ void RegisterSMTPParsers(void) /***************************************Unittests******************************/ +#ifdef UNITTESTS + /* * \test Test STARTTLS. */ @@ -2932,8 +2936,11 @@ end: return result; } +#endif /* UNITTESTS */ + void SMTPParserRegisterTests(void) { +#ifdef UNITTESTS UtRegisterTest("SMTPParserTest01", SMTPParserTest01, 1); UtRegisterTest("SMTPParserTest02", SMTPParserTest02, 1); UtRegisterTest("SMTPParserTest03", SMTPParserTest03, 1); @@ -2945,6 +2952,7 @@ void SMTPParserRegisterTests(void) UtRegisterTest("SMTPParserTest09", SMTPParserTest09, 1); UtRegisterTest("SMTPParserTest10", SMTPParserTest10, 1); UtRegisterTest("SMTPParserTest11", SMTPParserTest11, 1); +#endif /* UNITTESTS */ return; }