mirror of
https://github.com/OISF/suricata.git
synced 2026-05-28 04:32:12 -04:00
reputation: deduplicate skipping empty lines/comments
Some checks failed
builds / Prepare dependencies (push) Has been cancelled
builds / Prepare cbindgen (push) Has been cancelled
CodeQL (Rust/C) / Analyze (push) Has been cancelled
docs / Prepare dependencies (push) Has been cancelled
docs / Prepare cbindgen (push) Has been cancelled
Nix Env Build / tests (push) Has been cancelled
Scan-build / Scan-build (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
builds / AlmaLinux 10 (schema, plugins) (push) Has been cancelled
builds / AlmaLinux 9 (schema, rust-checks) (push) Has been cancelled
builds / AlmaLinux 9 Test Templates (push) Has been cancelled
builds / Build RPMs (push) Has been cancelled
builds / AlmaLinux 8 (push) Has been cancelled
builds / CentOS Stream 9 (push) Has been cancelled
builds / Fedora 43 (Suricata Verify codecov) (push) Has been cancelled
builds / Fedora 43 (clang, debug, asan, wshadow, rust-strict, systemd) (push) Has been cancelled
builds / Fedora 43 (gcc, debug, flto, asan, wshadow, rust-strict) (push) Has been cancelled
builds / Fedora (non-root, debug, clang, asan, wshadow, rust-strict, no-ja) (push) Has been cancelled
builds / AlmaLinux 9 (no jansson) (push) Has been cancelled
builds / AlmaLinux 9 (Minimal/Recommended Build) (push) Has been cancelled
builds / Ubuntu 24.04 (cocci) (push) Has been cancelled
builds / Ubuntu 24.04 (RUSTC+CARGO vars) (push) Has been cancelled
builds / Ubuntu 24.04 (unittests coverage) (push) Has been cancelled
builds / Ubuntu 24.04 (unix socket mode coverage) (push) Has been cancelled
builds / Ubuntu 24.04 (afpacket and dpdk coverage) (push) Has been cancelled
builds / Ubuntu 24.04 (pcap unix socket ASAN) (push) Has been cancelled
builds / Ubuntu 24.04 (afpacket IPS tests in namespaces) (push) Has been cancelled
builds / Ubuntu 24.04 (afpacket and dpdk live tests with ASAN) (push) Has been cancelled
builds / Ubuntu 24.04 (fuzz corpus coverage) (push) Has been cancelled
builds / Ubuntu 20.04 (-DNDEBUG) (push) Has been cancelled
builds / Ubuntu 20.04 (unsupported rust) (push) Has been cancelled
builds / Ubuntu 22.04 (Debug Validation) (push) Has been cancelled
builds / Ubuntu 22.04 (Fuzz) (push) Has been cancelled
builds / Ubuntu 22.04 (Netmap build) (push) Has been cancelled
builds / Ubuntu 22.04 (Minimal/Recommended Build) (push) Has been cancelled
builds / Ubuntu 22.04 (DPDK Build) (push) Has been cancelled
builds / Debian 12 (xdp) (push) Has been cancelled
builds / Debian 13 (xdp) (push) Has been cancelled
builds / Ubuntu 22.04 Dist Builder (push) Has been cancelled
builds / Debian 12 MSRV (push) Has been cancelled
builds / Debian 11 (push) Has been cancelled
builds / MacOS Latest (push) Has been cancelled
builds / Windows MSYS2 MINGW64 (NPcap) (push) Has been cancelled
builds / Windows MSYS2 MINGW64 (libpcap) (push) Has been cancelled
builds / Windows MSYS2 UCRT64 (libpcap) (push) Has been cancelled
builds / Windows MSYS2 MINGW64 (WinDivert) (push) Has been cancelled
builds / PF_RING (push) Has been cancelled
docs / Ubuntu 22.04 Dist Builder (push) Has been cancelled
Some checks failed
builds / Prepare dependencies (push) Has been cancelled
builds / Prepare cbindgen (push) Has been cancelled
CodeQL (Rust/C) / Analyze (push) Has been cancelled
docs / Prepare dependencies (push) Has been cancelled
docs / Prepare cbindgen (push) Has been cancelled
Nix Env Build / tests (push) Has been cancelled
Scan-build / Scan-build (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
builds / AlmaLinux 10 (schema, plugins) (push) Has been cancelled
builds / AlmaLinux 9 (schema, rust-checks) (push) Has been cancelled
builds / AlmaLinux 9 Test Templates (push) Has been cancelled
builds / Build RPMs (push) Has been cancelled
builds / AlmaLinux 8 (push) Has been cancelled
builds / CentOS Stream 9 (push) Has been cancelled
builds / Fedora 43 (Suricata Verify codecov) (push) Has been cancelled
builds / Fedora 43 (clang, debug, asan, wshadow, rust-strict, systemd) (push) Has been cancelled
builds / Fedora 43 (gcc, debug, flto, asan, wshadow, rust-strict) (push) Has been cancelled
builds / Fedora (non-root, debug, clang, asan, wshadow, rust-strict, no-ja) (push) Has been cancelled
builds / AlmaLinux 9 (no jansson) (push) Has been cancelled
builds / AlmaLinux 9 (Minimal/Recommended Build) (push) Has been cancelled
builds / Ubuntu 24.04 (cocci) (push) Has been cancelled
builds / Ubuntu 24.04 (RUSTC+CARGO vars) (push) Has been cancelled
builds / Ubuntu 24.04 (unittests coverage) (push) Has been cancelled
builds / Ubuntu 24.04 (unix socket mode coverage) (push) Has been cancelled
builds / Ubuntu 24.04 (afpacket and dpdk coverage) (push) Has been cancelled
builds / Ubuntu 24.04 (pcap unix socket ASAN) (push) Has been cancelled
builds / Ubuntu 24.04 (afpacket IPS tests in namespaces) (push) Has been cancelled
builds / Ubuntu 24.04 (afpacket and dpdk live tests with ASAN) (push) Has been cancelled
builds / Ubuntu 24.04 (fuzz corpus coverage) (push) Has been cancelled
builds / Ubuntu 20.04 (-DNDEBUG) (push) Has been cancelled
builds / Ubuntu 20.04 (unsupported rust) (push) Has been cancelled
builds / Ubuntu 22.04 (Debug Validation) (push) Has been cancelled
builds / Ubuntu 22.04 (Fuzz) (push) Has been cancelled
builds / Ubuntu 22.04 (Netmap build) (push) Has been cancelled
builds / Ubuntu 22.04 (Minimal/Recommended Build) (push) Has been cancelled
builds / Ubuntu 22.04 (DPDK Build) (push) Has been cancelled
builds / Debian 12 (xdp) (push) Has been cancelled
builds / Debian 13 (xdp) (push) Has been cancelled
builds / Ubuntu 22.04 Dist Builder (push) Has been cancelled
builds / Debian 12 MSRV (push) Has been cancelled
builds / Debian 11 (push) Has been cancelled
builds / MacOS Latest (push) Has been cancelled
builds / Windows MSYS2 MINGW64 (NPcap) (push) Has been cancelled
builds / Windows MSYS2 MINGW64 (libpcap) (push) Has been cancelled
builds / Windows MSYS2 UCRT64 (libpcap) (push) Has been cancelled
builds / Windows MSYS2 MINGW64 (WinDivert) (push) Has been cancelled
builds / PF_RING (push) Has been cancelled
docs / Ubuntu 22.04 Dist Builder (push) Has been cancelled
This commit is contained in:
parent
2e22ba65e7
commit
bb4e79c4f7
1 changed files with 13 additions and 18 deletions
|
|
@ -354,6 +354,17 @@ static int SRepLoadCatFile(const char *filename)
|
|||
return r;
|
||||
}
|
||||
|
||||
static inline size_t GetEffectiveLineLen(const char *line)
|
||||
{
|
||||
size_t len = strlen(line);
|
||||
/* ignore comments and empty lines */
|
||||
if (len == 0 || line[0] == '\n' || line[0] == '\r' || line[0] == ' ' || line[0] == '#' ||
|
||||
line[0] == '\t')
|
||||
return 0;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int SRepLoadCatFileFromFD(FILE *fp)
|
||||
{
|
||||
char line[8192] = "";
|
||||
|
|
@ -365,19 +376,11 @@ int SRepLoadCatFileFromFD(FILE *fp)
|
|||
BUG_ON(SRepGetVersion() > 0);
|
||||
|
||||
while(fgets(line, (int)sizeof(line), fp) != NULL) {
|
||||
size_t len = strlen(line);
|
||||
size_t len = GetEffectiveLineLen(line);
|
||||
if (len == 0)
|
||||
continue;
|
||||
|
||||
/* ignore comments and empty lines */
|
||||
if (line[0] == '\n' || line [0] == '\r' || line[0] == ' ' || line[0] == '#' || line[0] == '\t')
|
||||
continue;
|
||||
|
||||
/* Check if we have a trailing newline, and remove it */
|
||||
len = strlen(line);
|
||||
if (len == 0)
|
||||
continue;
|
||||
|
||||
if (line[len - 1] == '\n' || line[len - 1] == '\r') {
|
||||
line[len - 1] = '\0';
|
||||
}
|
||||
|
|
@ -423,19 +426,11 @@ int SRepLoadFileFromFD(SRepCIDRTree *cidr_ctx, FILE *fp)
|
|||
char line[8192] = "";
|
||||
|
||||
while(fgets(line, (int)sizeof(line), fp) != NULL) {
|
||||
size_t len = strlen(line);
|
||||
size_t len = GetEffectiveLineLen(line);
|
||||
if (len == 0)
|
||||
continue;
|
||||
|
||||
/* ignore comments and empty lines */
|
||||
if (line[0] == '\n' || line [0] == '\r' || line[0] == ' ' || line[0] == '#' || line[0] == '\t')
|
||||
continue;
|
||||
|
||||
/* Check if we have a trailing newline, and remove it */
|
||||
len = strlen(line);
|
||||
if (len == 0)
|
||||
continue;
|
||||
|
||||
if (line[len - 1] == '\n' || line[len - 1] == '\r') {
|
||||
line[len - 1] = '\0';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue