From: Jason Ish Date: Tue, 21 Nov 2017 20:01:21 +0000 (-0600) Subject: detect-parse: string copy not required X-Git-Tag: suricata-4.1.0-beta1~527 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0846cc561910ecc14404e0a17b80fa61f45fe79;p=thirdparty%2Fsuricata.git detect-parse: string copy not required Without using pcre, copies of the strings are no longer required. --- diff --git a/src/detect-parse.c b/src/detect-parse.c index af03098c9b..9f6f37c994 100644 --- a/src/detect-parse.c +++ b/src/detect-parse.c @@ -556,8 +556,8 @@ int SigMatchListSMBelongsTo(const Signature *s, const SigMatch *key_sm) static int SigParseOptions(DetectEngineCtx *de_ctx, Signature *s, char *optstr, char *output, size_t output_size) { SigTableElmt *st = NULL; - char optname[64]; - char optvalue[DETECT_MAX_RULE_SIZE] = ""; + char *optname = NULL; + char *optvalue = NULL; /* Trim leading space. */ while (isblank(*optstr)) { @@ -594,7 +594,7 @@ static int SigParseOptions(DetectEngineCtx *de_ctx, Signature *s, char *optstr, } } - strlcpy(optvalue, optvalptr, sizeof(optvalue)); + optvalue = optvalptr; } /* Trim trailing space from name. */ @@ -605,7 +605,7 @@ static int SigParseOptions(DetectEngineCtx *de_ctx, Signature *s, char *optstr, break; } } - strlcpy(optname, optstr, sizeof(optname)); + optname = optstr; /* Call option parsing */ st = SigTableGet(optname); @@ -615,7 +615,7 @@ static int SigParseOptions(DetectEngineCtx *de_ctx, Signature *s, char *optstr, } if (!(st->flags & (SIGMATCH_NOOPT|SIGMATCH_OPTIONAL_OPT))) { - if (strlen(optvalue) == 0) { + if (optvalue == NULL || strlen(optvalue) == 0) { SCLogError(SC_ERR_INVALID_SIGNATURE, "invalid formatting or malformed option to %s keyword: \'%s\'", optname, optstr); goto error; @@ -624,7 +624,7 @@ static int SigParseOptions(DetectEngineCtx *de_ctx, Signature *s, char *optstr, s->init_data->negated = false; /* Validate double quoting, trimming trailing white space along the way. */ - if (strlen(optvalue) > 0) { + if (optvalue != NULL && strlen(optvalue) > 0) { size_t ovlen = strlen(optvalue); char *ptr = optvalue;