From 12dc4152b5397b3d00f81a8c27853eae15ed5f9c Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Wed, 27 Mar 2013 09:30:24 +0100 Subject: [PATCH] trafgen: lexer: return if no needle found Also return if no needle has been found in the shell code haystack. Signed-off-by: Daniel Borkmann --- trafgen_lexer.l | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/trafgen_lexer.l b/trafgen_lexer.l index 2df1881f..20b6efe2 100644 --- a/trafgen_lexer.l +++ b/trafgen_lexer.l @@ -14,15 +14,18 @@ #include #include #include +#include #include "trafgen_parser.tab.h" #include "xmalloc.h" +#include "built_in.h" extern void yyerror(const char *); static char *try_convert_shellcode(char *sstr) { int j = 0; + bool found_any = false; char *bstr, *ostr = sstr, *hay; size_t blen, slen = strlen(sstr), tot = 0; const char *needle = "\\x"; @@ -37,14 +40,12 @@ static char *try_convert_shellcode(char *sstr) hay = sstr; while ((hay = strstr(hay, needle)) != NULL ) { hay += strlen(needle) + 2; + found_any = true; tot++; } - if (blen != tot) { - printf("Warning: mixed shellcode with strings, " - "using strings!\n"); + if (blen != tot || !found_any) return sstr; - } blen += 2; bstr = xzmalloc(blen); -- 2.11.4.GIT