Skip to content

Commit

Permalink
path: Backport fix-ups
Browse files Browse the repository at this point in the history
  • Loading branch information
jlucovsky committed Aug 22, 2023
1 parent f9bc6cb commit bfb3ec1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/detect-engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -3307,7 +3307,7 @@ static int DetectEngineMultiTenantLoadTenant(uint32_t tenant_id, const char *fil

SCStat st;
if (SCStatFn(filename, &st) != 0) {
SCLogError("failed to stat file %s", filename);
SCLogError(SC_ERR_STAT, "failed to stat file %s", filename);
goto error;
}

Expand Down
8 changes: 3 additions & 5 deletions src/suricata.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,10 @@
#include "util-cpu.h"
#include "util-daemon.h"
#include "util-device.h"
#include "util-dpdk.h"
#include "util-ebpf.h"
#include "util-exception-policy.h"
#include "util-host-os-info.h"
#include "util-ioctl.h"
#include "util-landlock.h"
#include "util-luajit.h"
#include "util-macset.h"
#include "util-misc.h"
Expand Down Expand Up @@ -538,12 +536,12 @@ static void SetBpfStringFromFile(char *filename)

fp = fopen(filename, "r");
if (fp == NULL) {
SCLogError("Failed to open file %s", filename);
SCLogError(SC_ERR_OPENING_FILE, "Failed to open file %s", filename);
exit(EXIT_FAILURE);
}

if (SCFstatFn(fileno(fp), &st) != 0) {
SCLogError("Failed to stat file %s", filename);
SCLogError(SC_ERR_STAT, "Failed to stat file %s", filename);
exit(EXIT_FAILURE);
}
bpf_len = st.st_size + 1;
Expand Down Expand Up @@ -1842,7 +1840,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
}
SCStat buf;
if (SCStatFn(optarg, &buf) != 0) {
SCLogError("pcap file '%s': %s", optarg, strerror(errno));
SCLogError(SC_ERR_INITIALIZATION, "pcap file '%s': %s", optarg, strerror(errno));
return TM_ECODE_FAILED;
}
if (ConfSetFinal("pcap-file.file", optarg) != 1) {
Expand Down
2 changes: 2 additions & 0 deletions src/util-error.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ const char * SCErrorToString(SCError err)
CASE_CODE(SC_WARN_CHOWN);
CASE_CODE(SC_ERR_HASH_ADD);
CASE_CODE(SC_ERR_SIGNAL);
CASE_CODE(SC_ERR_PATH_JOIN);
CASE_CODE(SC_ERR_PATH_RESOLVE);

CASE_CODE (SC_ERR_MAX);
}
Expand Down
2 changes: 2 additions & 0 deletions src/util-error.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ typedef enum {
SC_WARN_CHOWN,
SC_ERR_HASH_ADD,
SC_ERR_SIGNAL,
SC_ERR_PATH_JOIN,
SC_ERR_PATH_RESOLVE,

SC_ERR_MAX
} SCError;
Expand Down
4 changes: 2 additions & 2 deletions src/util-path.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ int PathJoin(char *out_buf, size_t buf_size, const char *const dir, const char *
return -1;
}
if (PathMerge(out_buf, buf_size, dir, fname) != 0) {
SCLogError("Could not join filename to path");
SCLogError(SC_ERR_PATH_JOIN, "Could not join filename to path");
return -1;
}
char *tmp_buf = SCRealPath(out_buf, NULL);
if (tmp_buf == NULL) {
SCLogError("Error resolving path: %s", strerror(errno));
SCLogError(SC_ERR_PATH_RESOLVE, "Error resolving path: %s", strerror(errno));
return -1;
}
memset(out_buf, 0, buf_size);
Expand Down

0 comments on commit bfb3ec1

Please sign in to comment.