#define MAX_SUBSTRINGS 30
int ret = 0, res = 0;
int ov[MAX_SUBSTRINGS];
- const char *key = NULL;
- const char *content = NULL;
+ char key[64] = "";
+ char content[1024] = "";
ret = pcre_exec(parse_regex, parse_regex_study, rawstr, strlen(rawstr),
0, 0, ov, MAX_SUBSTRINGS);
}
memset(ref, 0, sizeof(DetectReference));
- res = pcre_get_substring((char *)rawstr, ov, MAX_SUBSTRINGS, 1, &key);
+ res = pcre_copy_substring((char *)rawstr, ov, MAX_SUBSTRINGS, 1, key, sizeof(key));
if (res < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_get_substring failed");
+ SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_copy_substring failed");
goto error;
}
- res = pcre_get_substring((char *)rawstr, ov, MAX_SUBSTRINGS, 2, &content);
+ res = pcre_copy_substring((char *)rawstr, ov, MAX_SUBSTRINGS, 2, content, sizeof(content));
if (res < 0) {
SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_get_substring failed");
goto error;
}
- if (key == NULL || content == NULL)
+ if (strlen(key) == 0 || strlen(content) == 0)
goto error;
SCRConfReference *lookup_ref_conf = SCRConfGetReference(key, de_ctx);
}
/* free the substrings */
- pcre_free_substring(key);
- pcre_free_substring(content);
SCReturnPtr(ref, "Reference");
error:
- if (key != NULL)
- pcre_free_substring(key);
- if (content != NULL)
- pcre_free_substring(content);
if (ref != NULL)
DetectReferenceFree(ref);