Skip to content

Commit b50d26f

Browse files
committed
pflog: print the ruleset if it's present.
Do that regardless of whether the subrule is present. Picked up from the OpenBSD tcpdump.
1 parent 5b278cf commit b50d26f

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ Friday, August 30, 2024 / The Tcpdump Group
148148
OSPF: Update LS-Ack printing not to run off the end of the packet.
149149
OSPF6: Fix an undefined behavior.
150150
pflog: use nd_ types in struct pfloghdr.
151+
pflog: print some additional fields from the header (picked up
152+
from the FreeBSD tcpdump).
151153
pflog: handle all types of pflog files (as best as can be done)
154+
pflog: print the ruleset if it's present, regardless of whether
155+
the subrule is present (picked up from the OpenBSD tcpdump).
152156
PPP: Check if there is some data to hexdump.
153157
PPP: Remove an extra colon before LCP Callback Operation.
154158
Use the buffer stack for de-escaping PPP; fixes CVE-2024-2397;

print-pflog.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,17 @@ pflog_print(netdissect_options *ndo, const struct pfloghdr *hdr)
350350

351351
rulenr = GET_BE_U_4(hdr->rulenr);
352352
subrulenr = GET_BE_U_4(hdr->subrulenr);
353-
if (subrulenr == (uint32_t)-1)
354-
ND_PRINT("rule %u/", rulenr);
355-
else {
356-
ND_PRINT("rule %u.", rulenr);
357-
nd_printjnp(ndo, (const u_char*)hdr->ruleset, PFLOG_RULESET_NAME_SIZE);
358-
ND_PRINT(".%u/", subrulenr);
353+
ND_PRINT("rule ");
354+
if (rulenr != (uint32_t)-1) {
355+
ND_PRINT("%u", rulenr);
356+
if (hdr->ruleset[0] != '\0') {
357+
ND_PRINT(".");
358+
nd_printjnp(ndo, (const u_char*)hdr->ruleset, PFLOG_RULESET_NAME_SIZE);
359+
}
360+
if (subrulenr != (uint32_t)-1)
361+
ND_PRINT(".%u", subrulenr);
359362
}
363+
ND_PRINT("/");
360364

361365
if (length == PFLOG_HEADER_LEN_FREEBSD)
362366
ND_PRINT("%s", tok2str(pf_reasons_freebsd, "unkn(%u)", GET_U_1(hdr->reason)));

0 commit comments

Comments
 (0)