From: Daniel Borkmann Date: Wed, 27 Mar 2013 08:30:24 +0000 (+0100) Subject: trafgen: lexer: return if no needle found X-Git-Tag: v0.5.8-rc1~407 X-Git-Url: https://repo.or.cz/w/netsniff-ng.git/commitdiff_plain/12dc4152b5397b3d00f81a8c27853eae15ed5f9c 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 --- 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);