]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/rawbytes: improve error message plus do minor cleanups
authorVictor Julien <victor@inliniac.net>
Fri, 14 Dec 2018 09:22:39 +0000 (10:22 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 14 Dec 2018 14:20:30 +0000 (15:20 +0100)
src/detect-rawbytes.c
src/util-error.c
src/util-error.h

index ba8d9dff7143ca10d9b0da4175c78fb67023f4cf..8118484f0ab1125f3fe930986b0d050643674fd1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2018 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -31,6 +31,7 @@
 #include "detect.h"
 #include "detect-parse.h"
 #include "detect-rawbytes.h"
+#include "detect-engine.h"
 
 #include "detect-content.h"
 #include "detect-pcre.h"
@@ -42,11 +43,7 @@ static int DetectRawbytesSetup (DetectEngineCtx *, Signature *, const char *);
 void DetectRawbytesRegister (void)
 {
     sigmatch_table[DETECT_RAWBYTES].name = "rawbytes";
-    sigmatch_table[DETECT_RAWBYTES].Match = NULL;
     sigmatch_table[DETECT_RAWBYTES].Setup = DetectRawbytesSetup;
-    sigmatch_table[DETECT_RAWBYTES].Free  = NULL;
-    sigmatch_table[DETECT_RAWBYTES].RegisterTests = NULL;
-
     sigmatch_table[DETECT_RAWBYTES].flags |= SIGMATCH_NOOPT;
 }
 
@@ -56,11 +53,13 @@ static int DetectRawbytesSetup (DetectEngineCtx *de_ctx, Signature *s, const cha
 
     if (nullstr != NULL) {
         SCLogError(SC_ERR_INVALID_VALUE, "rawbytes has no value");
-        return -1;
+        SCReturnInt(-1);
     }
 
     if (s->init_data->list != DETECT_SM_LIST_NOTSET) {
-        SCLogError(SC_ERR_RAWBYTES_FILE_DATA, "\"rawbytes\" cannot be combined with \"file_data\"");
+        SCLogError(SC_ERR_RAWBYTES_BUFFER, "\"rawbytes\" cannot be combined "
+                "with the \"%s\" sticky buffer",
+                DetectBufferTypeGetNameById(de_ctx, s->init_data->list));
         SCReturnInt(-1);
     }
 
index ecdfe57d3f6b4bc58c3410e1c3265c2b37dc60ed..6cd3bb44688de9796d640af5ccc9927c2519aff0 100644 (file)
@@ -240,7 +240,7 @@ const char * SCErrorToString(SCError err)
         CASE_CODE (SC_ERR_AFP_DISPATCH);
         CASE_CODE (SC_ERR_CMD_LINE);
         CASE_CODE (SC_ERR_SIZE_PARSE);
-        CASE_CODE (SC_ERR_RAWBYTES_FILE_DATA);
+        CASE_CODE (SC_ERR_RAWBYTES_BUFFER);
         CASE_CODE (SC_ERR_SOCKET);
         CASE_CODE (SC_ERR_PCAP_TRANSLATE);
         CASE_CODE (SC_WARN_OUTDATED_LIBHTP);
index cfa74b0212f0d7a0f2ef7f29eeae5d2e347b7d89..6f0bad32572e162772b5b8e3d0a58813f371a9e8 100644 (file)
@@ -228,7 +228,7 @@ typedef enum {
     SC_ERR_MAGIC_OPEN,
     SC_ERR_MAGIC_LOAD,
     SC_ERR_SIZE_PARSE,
-    SC_ERR_RAWBYTES_FILE_DATA,
+    SC_ERR_RAWBYTES_BUFFER,
     SC_ERR_SOCKET,
     SC_ERR_PCAP_TRANSLATE,          /* failed to translate ip to dev */
     SC_WARN_OUTDATED_LIBHTP,