Skip to content

Commit 3f79004

Browse files
committed
pmrfc3164: accept IPv6 host tokens
Keep IPv6-based syslog sources interoperable in legacy RFC3164 pipelines without manual header cleanup. Before: IPv6 literals in HOSTNAME stopped parsing and After: IPv6 literals are accepted as HOSTNAME tokens. Impact: fixes user-visible RFC3164 forwarding for IPv6 hosts. Recognize IPv6 literals when the hostname scan hits a colon and validate the full token with inet_pton before accepting it. Honor permit.squarebracketsinhostname when brackets are present. Consume the hostname token and trailing space to keep TAG parsing in sync with RFC3164 expectations. Add a regression test for IPv6 HOSTNAME parsing. Tests: not run (not requested). Fixes: rsyslog#3012 With the help of AI-Agents: GPT-5.2-Codex
1 parent 3a7b661 commit 3f79004

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

tests/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ TESTS += \
179179
prop-programname-with-slashes.sh \
180180
hostname-with-slash-pmrfc5424.sh \
181181
hostname-with-slash-pmrfc3164.sh \
182+
pmrfc3164-ipv6-hostname.sh \
182183
hostname-with-slash-dflt-invld.sh \
183184
func-substring-invld-startpos.sh \
184185
func-substring-large-endpos.sh \
@@ -2087,6 +2088,7 @@ EXTRA_DIST= \
20872088
func-substring-relative-endpos.sh \
20882089
hostname-with-slash-pmrfc5424.sh \
20892090
hostname-with-slash-pmrfc3164.sh \
2091+
pmrfc3164-ipv6-hostname.sh \
20902092
pmrfc3164-msgFirstSpace.sh \
20912093
pmrfc3164-AtSignsInHostname.sh \
20922094
pmrfc3164-AtSignsInHostname_off.sh \

tests/pmrfc3164-ipv6-hostname.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
## Test RFC3164 parser accepts IPv6 literals as HOSTNAME.
3+
. ${srcdir:=.}/diag.sh init
4+
generate_conf
5+
add_conf '
6+
module(load="../plugins/imtcp/.libs/imtcp")
7+
input(type="imtcp" port="0" listenPortFileName="'$RSYSLOG_DYNNAME'.tcpflood_port" ruleset="customparser")
8+
parser(name="custom.rfc3164" type="pmrfc3164" permit.squarebracketsinhostname="on")
9+
template(name="outfmt" type="string" string="%hostname%\n")
10+
11+
ruleset(name="customparser" parser="custom.rfc3164") {
12+
action(type="omfile" template="outfmt" file="'$RSYSLOG_OUT_LOG'")
13+
}
14+
'
15+
startup
16+
tcpflood -m1 -M "\"<129>Mar 10 01:00:00 2001:db8::1 tag: msgnum:1\""
17+
tcpflood -m1 -M "\"<129>Mar 10 01:00:00 [2001:db8::2] tag: msgnum:2\""
18+
shutdown_when_empty
19+
wait_shutdown
20+
export EXPECTED='2001:db8::1
21+
[2001:db8::2]'
22+
cmp_exact
23+
24+
exit_test

0 commit comments

Comments
 (0)