From 3fa958b9a78fb5c0564c798ac95de0c1f9eb4771 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Wed, 26 Feb 2014 06:28:30 +0100 Subject: [PATCH] byte_extract/test/jump: fix coverity issues During keyword setup there was a path that in theory could lead to indexing an array with a negative int. Coverity 992695, 400605, 400604 --- src/detect-byte-extract.c | 2 ++ src/detect-bytejump.c | 4 ++++ src/detect-bytetest.c | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/src/detect-byte-extract.c b/src/detect-byte-extract.c index 948a996623..9eae71eb78 100644 --- a/src/detect-byte-extract.c +++ b/src/detect-byte-extract.c @@ -574,6 +574,8 @@ int DetectByteExtractSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) sm_list = DETECT_SM_LIST_PMATCH; } else { sm_list = SigMatchListSMBelongsTo(s, prev_pm); + if (sm_list < 0) + goto error; } } else { sm_list = DETECT_SM_LIST_PMATCH; diff --git a/src/detect-bytejump.c b/src/detect-bytejump.c index 9549e8e4ca..c2e0da0c3d 100644 --- a/src/detect-bytejump.c +++ b/src/detect-bytejump.c @@ -568,6 +568,8 @@ int DetectBytejumpSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr) sm_list = DETECT_SM_LIST_PMATCH; } else { sm_list = SigMatchListSMBelongsTo(s, prev_pm); + if (sm_list < 0) + goto error; } } else { sm_list = DETECT_SM_LIST_PMATCH; @@ -671,6 +673,8 @@ int DetectBytejumpSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr) sm_list = DETECT_SM_LIST_PMATCH; } else { sm_list = SigMatchListSMBelongsTo(s, prev_pm); + if (sm_list < 0) + goto error; } } else { diff --git a/src/detect-bytetest.c b/src/detect-bytetest.c index 661bb310c9..25d731fb4d 100644 --- a/src/detect-bytetest.c +++ b/src/detect-bytetest.c @@ -489,6 +489,8 @@ int DetectBytetestSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr) sm_list = DETECT_SM_LIST_PMATCH; } else { sm_list = SigMatchListSMBelongsTo(s, prev_pm); + if (sm_list < 0) + goto error; } } else { sm_list = DETECT_SM_LIST_PMATCH; @@ -592,6 +594,8 @@ int DetectBytetestSetup(DetectEngineCtx *de_ctx, Signature *s, char *optstr) sm_list = DETECT_SM_LIST_PMATCH; } else { sm_list = SigMatchListSMBelongsTo(s, prev_pm); + if (sm_list < 0) + goto error; } } else {