host-info: remove pcre2_substring_list_free use

Function prototype has changed in a recent release. Rather than dealing
with detecting that, fall back to our regular pattern of using
pcre2_substring_copy_bynumber().

Bug: #6918.
pull/10768/head
Victor Julien 11 months ago committed by Victor Julien
parent d310d00eb0
commit b224209f45

@ -44,7 +44,6 @@ int SCKernelVersionIsAtLeast(int major, int minor)
PCRE2_SIZE eo;
int ret;
int kmajor, kminor;
PCRE2_UCHAR **list;
/* get local version */
if (uname(&kuname) != 0) {
@ -79,25 +78,36 @@ int SCKernelVersionIsAtLeast(int major, int minor)
goto error;
}
pcre2_substring_list_get(version_regex_match, &list, NULL);
char majorstr[32];
size_t pcre2len = sizeof(majorstr);
ret = pcre2_substring_copy_bynumber(
version_regex_match, 1, (PCRE2_UCHAR8 *)majorstr, &pcre2len);
if (ret < 0) {
SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
bool err = false;
if (StringParseInt32(&kmajor, 10, 0, (const char *)list[1]) < 0) {
SCLogError("Invalid value for kmajor: '%s'", list[1]);
err = true;
char minorstr[32];
pcre2len = sizeof(majorstr);
ret = pcre2_substring_copy_bynumber(
version_regex_match, 2, (PCRE2_UCHAR8 *)minorstr, &pcre2len);
if (ret < 0) {
SCLogError("pcre2_substring_copy_bynumber failed");
goto error;
}
if (StringParseInt32(&kminor, 10, 0, (const char *)list[2]) < 0) {
SCLogError("Invalid value for kminor: '%s'", list[2]);
err = true;
if (StringParseInt32(&kmajor, 10, 0, (const char *)majorstr) < 0) {
SCLogError("Invalid value for kmajor: '%s'", minorstr);
goto error;
}
if (StringParseInt32(&kminor, 10, 0, (const char *)minorstr) < 0) {
SCLogError("Invalid value for kminor: '%s'", minorstr);
goto error;
}
pcre2_substring_list_free((PCRE2_SPTR *)list);
pcre2_match_data_free(version_regex_match);
pcre2_code_free(version_regex);
if (err)
goto error;
if (kmajor > major)
return 1;
if (kmajor == major && kminor >= minor)

Loading…
Cancel
Save