From: Shivani Bhardwaj Date: Sat, 10 Aug 2019 18:05:04 +0000 (+0530) Subject: src/detect: check DetectBufferSetActiveList return code X-Git-Tag: suricata-5.0.0-rc1~160 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26bc0d6e1d27c37f0fdf631e9110748b22014e34;p=thirdparty%2Fsuricata.git src/detect: check DetectBufferSetActiveList return code Make sure to always check the return codes of DetectBufferSetActiveList. Also, force this warning on function prototype. Closes redmine ticket #3005. --- diff --git a/src/detect-engine.h b/src/detect-engine.h index 02882f52fe..1e877a06c3 100644 --- a/src/detect-engine.h +++ b/src/detect-engine.h @@ -164,7 +164,7 @@ void DetectEngineSetParseMetadata(void); void DetectEngineUnsetParseMetadata(void); int DetectEngineMustParseMetadata(void); -int DetectBufferSetActiveList(Signature *s, const int list); +int WARN_UNUSED DetectBufferSetActiveList(Signature *s, const int list); int DetectBufferGetActiveList(DetectEngineCtx *de_ctx, Signature *s); #endif /* __DETECT_ENGINE_H__ */ diff --git a/src/detect-file-data.c b/src/detect-file-data.c index d47f6c5e59..6065ed04f2 100644 --- a/src/detect-file-data.c +++ b/src/detect-file-data.c @@ -190,7 +190,8 @@ static int DetectFiledataSetup (DetectEngineCtx *de_ctx, Signature *s, const cha return -1; } - DetectBufferSetActiveList(s, DetectBufferTypeGetByName("file_data")); + if (DetectBufferSetActiveList(s, DetectBufferTypeGetByName("file_data")) < 0) + return -1; SetupDetectEngineConfig(de_ctx); return 0; diff --git a/src/detect-http-cookie.c b/src/detect-http-cookie.c index 84030b0ddb..d9443b0e69 100644 --- a/src/detect-http-cookie.c +++ b/src/detect-http-cookie.c @@ -152,7 +152,9 @@ static int DetectHttpCookieSetup(DetectEngineCtx *de_ctx, Signature *s, const ch */ static int DetectHttpCookieSetupSticky(DetectEngineCtx *de_ctx, Signature *s, const char *str) { - DetectBufferSetActiveList(s, g_http_cookie_buffer_id); + if (DetectBufferSetActiveList(s, g_http_cookie_buffer_id) < 0) + return -1; + s->alproto = ALPROTO_HTTP; return 0; } diff --git a/src/detect-http-stat-code.c b/src/detect-http-stat-code.c index da191ea469..7a5cdf6b14 100644 --- a/src/detect-http-stat-code.c +++ b/src/detect-http-stat-code.c @@ -140,7 +140,8 @@ static int DetectHttpStatCodeSetup(DetectEngineCtx *de_ctx, Signature *s, const */ static int DetectHttpStatCodeSetupSticky(DetectEngineCtx *de_ctx, Signature *s, const char *str) { - DetectBufferSetActiveList(s, g_http_stat_code_buffer_id); + if (DetectBufferSetActiveList(s, g_http_stat_code_buffer_id) < 0) + return -1; s->alproto = ALPROTO_HTTP; return 0; } diff --git a/src/detect-http-stat-msg.c b/src/detect-http-stat-msg.c index a38a3a9724..a5d08ba72d 100644 --- a/src/detect-http-stat-msg.c +++ b/src/detect-http-stat-msg.c @@ -140,7 +140,8 @@ static int DetectHttpStatMsgSetup(DetectEngineCtx *de_ctx, Signature *s, const c */ static int DetectHttpStatMsgSetupSticky(DetectEngineCtx *de_ctx, Signature *s, const char *str) { - DetectBufferSetActiveList(s, g_http_stat_msg_buffer_id); + if (DetectBufferSetActiveList(s, g_http_stat_msg_buffer_id) < 0) + return -1; s->alproto = ALPROTO_HTTP; return 0; } diff --git a/src/detect-http-uri.c b/src/detect-http-uri.c index 8a880b70f2..8df0ed562f 100644 --- a/src/detect-http-uri.c +++ b/src/detect-http-uri.c @@ -202,7 +202,8 @@ static void DetectHttpUriSetupCallback(const DetectEngineCtx *de_ctx, */ static int DetectHttpUriSetupSticky(DetectEngineCtx *de_ctx, Signature *s, const char *str) { - DetectBufferSetActiveList(s, g_http_uri_buffer_id); + if (DetectBufferSetActiveList(s, g_http_uri_buffer_id) < 0) + return -1; s->alproto = ALPROTO_HTTP; return 0; } @@ -274,7 +275,8 @@ static void DetectHttpRawUriSetupCallback(const DetectEngineCtx *de_ctx, */ static int DetectHttpRawUriSetupSticky(DetectEngineCtx *de_ctx, Signature *s, const char *str) { - DetectBufferSetActiveList(s, g_http_raw_uri_buffer_id); + if (DetectBufferSetActiveList(s, g_http_raw_uri_buffer_id) < 0) + return -1; s->alproto = ALPROTO_HTTP; return 0; }