Skip to content

Conversation

@julthomas
Copy link

Hello @rgerhards,

As discussed on ML and private, here is a branch that contains 2 patches criticals for our production. This PR is aligned with current stable branch (2.0.7). Patches will apply on current master as well.

Following 2.0.7 release, I believe a number of issues or PR could be closed (there are probably more). A cleanup would not harm.

merics and others added 2 commits October 21, 2025 16:12
In struct data_String, the perm_chars member is declared as
an array indexed from 0 to 255:

    char perm_chars[256];

Bytes > 127, for instance with UTF-8 data, cause a segfault.
I believe casting as (unsigned char) instead of (unsigned) should
ensure the perm_chars is accessed at index 0..255.

I came this segfault with the following string sample. Rsyslog crashes
in stringIsPermittedChar() when it processes char byte 0xe2.

echo 'd’ouverture' |od -t x1 -a
0000000  64  e2  80  99  6f  75  76  65  72  74  75  72  65  0a
          d   b nul  em   o   u   v   e   r   t   u   r   e  nl
0000016

Note line numbers in parser.c reported by gdb are wrong with master
because it is from a 2.0.6 version with other patches:

#0  0x00007f9a73034713 in stringIsPermittedChar (data=0x55bd3a1a42a0, c=-30 '\342') at parser.c:3236
rsyslog#1  0x00007f9a73034c63 in ln_v2_parseString (npb=0x7f9a5292d670, offs=0x7f9a5292d600, pdata=0x55bd3a1a42a0, parsed=0x7f9a5292d5f8, value=0x7f9a5292d5f0) at parser.c:3363
rsyslog#2  0x00007f9a73029279 in tryParser (npb=0x7f9a5292d670, dag=0x55bd3a1a11a0, offs=0x7f9a5292d600, pParsed=0x7f9a5292d5f8, value=0x7f9a5292d5f0, prs=0x55bd3a14ea00) at pdag.c:1454
rsyslog#3  0x00007f9a730295db in ln_normalizeRec (npb=0x7f9a5292d670, dag=0x55bd3a1a11a0, offs=0, bPartialMatch=0, json=0x7f9a4c4dd260, endNode=0x7f9a5292d6a0) at pdag.c:1575
rsyslog#4  0x00007f9a730299ac in ln_normalize (ctx=0x55bd3a14e680, str=0x7f9a4c4e19a0 "d’ouverture de session :rsyslog#11#011{837B856E-32B3-78E2-3D77-4E95F8904E71}rsyslog#15#012#015#012Informations sur le processus :rsyslog#15#012#011ID du processus :rsyslog#11#0110x0#015#012#011Nom du processus :rsyslog#11#01"..., strLen=8021, json_p=0x7f9a5292d6d8) at pdag.c:1653
rsyslog#5  0x00007f9a7302459e in doAction (pMsgData=0x7f9a5292d740, pWrkrData=0x7f9a4c4daad0) at mmnormalize.c:259
...

This should fix issue rsyslog#340 "UTF-8 accentuated
characters causing segfault". The patch in this pull request is
also similar.
@gemini-code-assist
Copy link

Summary of Changes

Hello @julthomas, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the stability and reliability of liblognorm for production environments. It introduces critical fixes to prevent memory leaks during custom type parsing failures and eliminates a segfault caused by incorrect character array indexing. Additionally, it aims to clean up and close several related issues following the 2.0.7 release, contributing to a more robust and maintainable codebase.

Highlights

  • Memory Leak Fix: Addressed a memory leak that occurred when a custom type in parsing rules did not match, ensuring proper resource deallocation.
  • Segfault Prevention: Resolved an out-of-bounds access issue in the stringIsPermittedChar function, which was causing segfaults, by correctly casting character values for array indexing.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses critical issues in liblognorm, specifically a memory leak and a potential segfault, along with a cleanup of issues following the 2.0.7 release. The changes include a fix for a memory leak when a custom type in rules does not match and a fix for an out-of-bounds access in perm_chars causing a segfault. The review focuses on the correctness and security aspects of these changes.

Comment on lines +1445 to +1447
if (r != 0) {
json_object_put(*value);
*value = NULL;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

When a custom parser fails (r != 0), the json_object pointed to by *value is freed, and *value is set to NULL. This is important to prevent memory leaks and ensure that the caller does not attempt to use a dangling pointer. Failing to do so could lead to memory corruption and program instability.

It's crucial to handle the error case where the custom parser fails to prevent memory leaks.

		json_object_put(*value);
		*value = NULL;

@rgerhards
Copy link
Member

thx, I'll have a more detailled look later this week. If you do not hear anything substantial after the weekend, I would appreciate a ping (but no force, would just be nice!).

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.

3 participants