From: Victor Julien Date: Fri, 14 Dec 2018 09:22:39 +0000 (+0100) Subject: detect/rawbytes: improve error message plus do minor cleanups X-Git-Tag: suricata-4.1.1~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=394e1150369c113f3560c5636ef172d65620af97;p=thirdparty%2Fsuricata.git detect/rawbytes: improve error message plus do minor cleanups --- diff --git a/src/detect-rawbytes.c b/src/detect-rawbytes.c index ba8d9dff71..8118484f0a 100644 --- a/src/detect-rawbytes.c +++ b/src/detect-rawbytes.c @@ -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); } diff --git a/src/util-error.c b/src/util-error.c index ecdfe57d3f..6cd3bb4468 100644 --- a/src/util-error.c +++ b/src/util-error.c @@ -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); diff --git a/src/util-error.h b/src/util-error.h index cfa74b0212..6f0bad3257 100644 --- a/src/util-error.h +++ b/src/util-error.h @@ -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,