From: Victor Julien Date: Tue, 3 Jul 2012 13:15:19 +0000 (+0200) Subject: Improve pktvar keyword parsing and error handling. X-Git-Tag: suricata-1.3~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7b36051de2e700f37116b7582106def5e344adf;p=thirdparty%2Fsuricata.git Improve pktvar keyword parsing and error handling. --- diff --git a/src/detect-pktvar.c b/src/detect-pktvar.c index 9f00bc002c..6973ede5a7 100644 --- a/src/detect-pktvar.c +++ b/src/detect-pktvar.c @@ -218,6 +218,12 @@ static int DetectPktvarSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawst } cd->name = SCStrdup(varname); + if (cd->name == NULL) { + SCFree(cd); + if (dubbed) SCFree(str); + return -1; + } + memcpy(cd->content, str, len); cd->content_len = len; cd->flags = 0; @@ -237,9 +243,15 @@ static int DetectPktvarSetup (DetectEngineCtx *de_ctx, Signature *s, char *rawst return 0; error: - if (dubbed) SCFree(str); - if (cd) SCFree(cd); - if (sm) SCFree(sm); + if (dubbed) + SCFree(str); + if (cd) { + if (cd->name) + SCFree(cd->name); + SCFree(cd); + } + if (sm) + SCFree(sm); return -1; }