summaryrefslogtreecommitdiff
path: root/trafgen_lexer.l
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-03-27 09:30:24 +0100
committerDaniel Borkmann <dborkman@redhat.com>2013-03-27 09:30:24 +0100
commit12dc4152b5397b3d00f81a8c27853eae15ed5f9c (patch)
tree19b7fb9346b1a74da5b74780bf8eeefba5874e11 /trafgen_lexer.l
parent7ffa9cc1715108ab89292aeffc392688af1f74da (diff)
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 <dborkman@redhat.com>
Diffstat (limited to 'trafgen_lexer.l')
-rw-r--r--trafgen_lexer.l9
1 files changed, 5 insertions, 4 deletions
diff --git a/trafgen_lexer.l b/trafgen_lexer.l
index 2df1881..20b6efe 100644
--- a/trafgen_lexer.l
+++ b/trafgen_lexer.l
@@ -14,15 +14,18 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
+#include <stdbool.h>
#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);