Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix passing the value to EscapeChar. #5377

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lonicerae
Copy link
Contributor

  • Properly handle the EscapeChar after refactor.

@rgerhards
Copy link
Member

Please elaborate which problem is fixing this and how. uid_t at this places looks somewhat strange.

@lonicerae
Copy link
Contributor Author

lonicerae commented May 8, 2024

Hi @rgerhards !

Sorry for the rush.. Segfault call trace as follows:

Core was generated by `rsyslogd -n'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000000000042f007 in setParserControlCharacterEscapePrefix (pVal=pVal@entry=0x0, pNewVal=0x2f <error: Cannot access memory at address 0x2f>) at glbl.c:524
524		loadConf->globals.parser.cCCEscapeChar = *pNewVal;
Missing separate debuginfos, use: dnf debuginfo-install libcap-2.48-5.fc37.x86_64 libestr-0.1.11-4.fc37.x86_64 libfastjson-0.99.9-4.fc37.x86_64 libgcc-12.3.1-1.fc37.x86_64 libuuid-2.38.1-1.fc37.x86_64 libzstd-1.5.5-1.fc37.x86_64 lz4-libs-1.9.4-1.fc37.x86_64 systemd-libs-251.19-1.fc37.x86_64 xz-libs-5.4.1-1.fc37.x86_64 zlib-1.2.12-5.fc37.x86_64
(gdb) bt
#0  0x000000000042f007 in setParserControlCharacterEscapePrefix (pVal=pVal@entry=0x0, pNewVal=0x2f <error: Cannot access memory at address 0x2f>) at glbl.c:524
#1  0x000000000046a256 in doGetChar (pp=0x7fff55bb7638, pSetHdlr=0x42f000 <setParserControlCharacterEscapePrefix>, pVal=0x0) at cfsysline.c:81
#2  0x000000000046b491 in cslchCallHdlr (ppConfLine=<optimized out>, pThis=<optimized out>) at cfsysline.c:782
#3  processCfSysLineCommand (pCmdName=pCmdName@entry=0x7fff55bb7690 "ControlCharacterEscapePrefix", p=p@entry=0x7fff55bb7688) at cfsysline.c:1022
#4  0x00000000004319cd in cfsysline (p=<optimized out>) at conf.c:239
#5  0x0000000000435a3b in cnfDoCfsysline (ln=0x125fcd0 "$ControlCharacterEscapePrefix /") at rsconf.c:628
#6  0x000000000042235d in yylex () at /home/shine/PROJ/rsyslog/grammar/lexer.l:434
#7  0x000000000041e58a in yyparse () at grammar.c:1408
#8  0x0000000000434e4d in load (cnf=0x4beee8 <ourConf>, confFile=0x47c74a "/etc/rsyslog.conf") at rsconf.c:1494
#9  0x000000000041105d in initAll (argc=argc@entry=2, argv=argv@entry=0x7fff55bb9728) at rsyslogd.c:1644
#10 0x000000000040f0ad in main (argc=2, argv=0x7fff55bb9728) at rsyslogd.c:2344
(gdb) f 1
#1  0x000000000046a256 in doGetChar (pp=0x7fff55bb7638, pSetHdlr=0x42f000 <setParserControlCharacterEscapePrefix>, pVal=0x0) at cfsysline.c:81
81				CHKiRet(pSetHdlr(pVal, **pp));
(gdb) p **pp
$1 = 47 '/'

I bisect the issue to commit 321fc76 . Seems it's a side effect after refactoring.

Relevant issue: #5376

@rgerhards
Copy link
Member

do you have a sample conf that trigges the behavior?

@lonicerae
Copy link
Contributor Author

Yes, the reproduction is easy. Just add this line to the /etc/rsyslog.conf:

$ControlCharacterEscapePrefix /

Or any char instead of the '/' can do.

The above call trace is from my Fedora + latest rsyslog.

Best regards,
Flos

@Cropi
Copy link
Collaborator

Cropi commented May 23, 2024

I see that in doGetChar, the handler function setParserControlCharacterEscapePrefix is called with the appropriate escape character, which is type of uchar. However, setParserControlCharacterEscapePrefix expects it to be uchar *, that's where the segfault happens.

I would rather use a different type than uid_t, as it's usually used to hold a used ID. Ideally a replacement could be uchar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants