detect/rawbytes: improve error message plus do minor cleanups

pull/3584/head
Victor Julien 7 years ago
parent f336ba3217
commit 394e115036

@ -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);
}

@ -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);

@ -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,

Loading…
Cancel
Save