int r;
int ov[MAX_SUBSTRINGS];
int retval = 0;
- const char *str_ptr = NULL;
- const char *str_ptr2 = NULL;
+ char str[128];
+ char str2[128];
*res = 0;
goto end;
}
- r = pcre_get_substring((char *)size, ov, MAX_SUBSTRINGS, 1,
- &str_ptr);
+ r = pcre_copy_substring((char *)size, ov, MAX_SUBSTRINGS, 1,
+ str, sizeof(str));
if (r < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_get_substring failed");
+ SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_copy_substring failed");
retval = -2;
goto end;
}
- char *endptr;
+ char *endptr, *str_ptr = str;
errno = 0;
*res = strtod(str_ptr, &endptr);
if (errno == ERANGE) {
}
if (pcre_exec_ret == 3) {
- r = pcre_get_substring((char *)size, ov, MAX_SUBSTRINGS, 2,
- &str_ptr2);
+ r = pcre_copy_substring((char *)size, ov, MAX_SUBSTRINGS, 2,
+ str2, sizeof(str2));
if (r < 0) {
- SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_get_substring failed");
+ SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_copy_substring failed");
retval = -2;
goto end;
}
- if (strcasecmp(str_ptr2, "kb") == 0) {
+ if (strcasecmp(str2, "kb") == 0) {
*res *= 1024;
- } else if (strcasecmp(str_ptr2, "mb") == 0) {
+ } else if (strcasecmp(str2, "mb") == 0) {
*res *= 1024 * 1024;
- } else if (strcasecmp(str_ptr2, "gb") == 0) {
+ } else if (strcasecmp(str2, "gb") == 0) {
*res *= 1024 * 1024 * 1024;
} else {
/* not possible */
retval = 0;
end:
- if (str_ptr != NULL)
- pcre_free_substring(str_ptr);
- if (str_ptr2 != NULL)
- pcre_free_substring(str_ptr2);
return retval;
}