Skip to content

Commit

Permalink
Fixes (squash before merging)
Browse files Browse the repository at this point in the history
  • Loading branch information
evgenyz committed Aug 29, 2023
1 parent 3651403 commit 0f91746
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
24 changes: 12 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,11 @@ find_package(Doxygen)
find_package(GConf)
find_package(Ldap)
find_package(OpenDbx)
find_package(PCRE)
find_package(PCRE2)
if(WITH_PCRE2)
find_package(PCRE2 REQUIRED)
else()
find_package(PCRE REQUIRED)
endif()
find_package(PerlLibs)
find_package(Popt)
find_package(Systemd)
Expand Down Expand Up @@ -194,16 +197,11 @@ else()
set(YAML_FILTER_FOUND FALSE)
endif()

# PCRE / PCRE2
if(PCRE2_FOUND OR PCRE_FOUND)
if (PCRE2_FOUND)
set(HAVE_PCRE2 1)
message("-- Using PCRE2")
else()
message("-- Using PCRE")
endif()
else()
message(SEND_ERROR "Required libraries PCRE or PCRE2 not found.")
if(PCRE2_FOUND)
set(HAVE_PCRE2 1)
message("-- Using PCRE2")
elseif(PCRE_FOUND)
message("-- Using PCRE")
endif()

check_library_exists(rt clock_gettime "" HAVE_CLOCK_GETTIME)
Expand Down Expand Up @@ -343,6 +341,8 @@ cmake_dependent_option(ENABLE_OSCAP_UTIL_CHROOT "enables the oscap-chroot utilit
option(ENABLE_OSCAP_UTIL_AUTOTAILOR "enables the autotailor utility that is able to perform command-line tailoring" TRUE)
option(ENABLE_OSCAP_REMEDIATE_SERVICE "enables the oscap-remediate service" FALSE)

option(WITH_PCRE2 "use PCRE2 library" FALSE)

# ---------- TEST-SUITE SWITCHES

# Tests will be turned off on Windows, because the test suite uses bash
Expand Down
4 changes: 2 additions & 2 deletions src/OVAL/probes/unix/linux/rpmverifyfile_probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ static int _compare_file_with_current_file(oval_operation_t file_op, const char
}
int pcre_ret = oscap_pcre_exec(re, current_file, strlen(current_file), 0, 0, NULL, 0);
oscap_pcre_free(re);
if (pcre_ret == 0) {
if (pcre_ret > OSCAP_PCRE_ERR_NOMATCH) {
/* match */
*result_file = oscap_strdup(current_file);
} else if (pcre_ret == -1) {
} else if (pcre_ret == OSCAP_PCRE_ERR_NOMATCH) {
/* no match */
ret = 1;
goto cleanup;
Expand Down
4 changes: 3 additions & 1 deletion src/common/oscap_pcre.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,12 @@ oscap_pcre_t* oscap_pcre_compile(const char *pattern, oscap_pcre_options_t optio
PCRE2_UCHAR8 err_msg[1024];
pcre2_get_error_message_8(errno, err_msg, 1024);
dW("pcre2_compile_8 error: %s", err_msg);
*erroffset = erroffs;
*errptr = strdup((const char*)err_msg);
}
#else
res->re_extra = NULL;
res->re = pcre_compile(pattern, _oscap_pcre_opts_to_pcre(options), errptr, erroffset, tableptr);
res->re = pcre_compile(pattern, _oscap_pcre_opts_to_pcre(options), errptr, erroffset, NULL);
#endif
if (res->re == NULL) {
free(res);
Expand Down

0 comments on commit 0f91746

Please sign in to comment.