Skip to content

Commit 662804b

Browse files
authored
Merge pull request #4064 from citrus-it/rsyslogr54
rsyslog: Fix buffer overrun (r151054)
2 parents 34d0fdb + 4e93917 commit 662804b

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

build/rsyslog/build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
# http://www.illumos.org/license/CDDL.
1313
# }}}
1414
#
15-
# Copyright 2025 OmniOS Community Edition (OmniOSce) Association.
15+
# Copyright 2026 OmniOS Community Edition (OmniOSce) Association.
1616

1717
. ../../lib/build.sh
1818

1919
PROG=rsyslog
2020
VER=8.2502.0
21+
DASHREV=1
2122
PKG=system/rsyslog
2223
SUMMARY="rsyslog - the rocket-fast system for log processing."
2324
DESC="A high-performance, modular syslog implementation."

build/rsyslog/patches/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ runtime-parser.c.patch
22
runtime-rsyslog.h.patch
33
logonly.patch
44
man.patch
5+
template.patch
56
test.patch
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
diff -wpruN --no-dereference '--exclude=*.orig' a~/template.c a/template.c
2+
--- a~/template.c 1970-01-01 00:00:00
3+
+++ a/template.c 1970-01-01 00:00:00
4+
@@ -192,7 +192,13 @@ tplToString(struct template *__restrict__ const pTpl,
5+
*/
6+
pTpe = pTpl->pEntryRoot;
7+
iBuf = 0;
8+
- const int extra_space = (pTpl->optFormatEscape == JSONF) ? 1 : 3;
9+
+ /*
10+
+ * We reserve one extra space for a trailing NUL. In the JSON case we
11+
+ * need to add space for an additional four characters, a potential
12+
+ * leading ", " if this is not the first value, and a trailing "}\n" if
13+
+ * it's the last.
14+
+ */
15+
+ const int extra_space = (pTpl->optFormatEscape == JSONF) ? 1 : 5;
16+
if(pTpl->optFormatEscape == JSONF) {
17+
if(iparam->lenBuf < 2) /* we reserve one char for the final \0! */
18+
CHKiRet(ExtendBuf(iparam, 2));
19+
@@ -228,8 +234,8 @@ tplToString(struct template *__restrict__ const pTpl,
20+
/* got source, now copy over */
21+
if(iLenVal > 0) { /* may be zero depending on property */
22+
/* first, make sure buffer fits */
23+
- if(iBuf + iLenVal + extra_space >= iparam->lenBuf) /* we reserve one char for the final \0! */
24+
- CHKiRet(ExtendBuf(iparam, iBuf + iLenVal + 1));
25+
+ if(iBuf + iLenVal + extra_space > iparam->lenBuf)
26+
+ CHKiRet(ExtendBuf(iparam, iBuf + iLenVal + extra_space));
27+
28+
if(need_comma) {
29+
memcpy(iparam->param + iBuf, ", ", 2);

0 commit comments

Comments
 (0)