detect-parse: string copy not required

Without using pcre, copies of the strings are no longer
required.
pull/3022/head
Jason Ish 9 years ago committed by Victor Julien
parent 73d1e4bc84
commit d0846cc561

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

Loading…
Cancel
Save