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

systemd-journal: fix spurious warning about about incorrect size passed to strncpy() #454

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

bazsi
Copy link
Member

@bazsi bazsi commented Jan 11, 2025

    .../modules/systemd-journal/journal-reader.c: In function '_get_value_from_message.constprop.isra':
    .../modules/systemd-journal/journal-reader.c:218:7: warning: '__builtin___strncpy_chk' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
      218 |       strncpy(buf + cont, key, key_len);
          |       ^
    In function '_format_value_name_with_prefix',
        inlined from '_get_value_from_message.constprop.isra' at /source/modules/systemd-journal/journal-reader.c:243:3:
    .../modules/systemd-journal/journal-reader.c:211:15: note: length computed here
      211 |     key_len = strlen(key);
          |               ^~~~~~~~~~~

This wasn't an actual issue as we were explicitly terminating the string with NUL in this case, so missing the NUL character was actually expected.

…ed to strncpy()

.../modules/systemd-journal/journal-reader.c: In function '_get_value_from_message.constprop.isra':
.../modules/systemd-journal/journal-reader.c:218:7: warning: '__builtin___strncpy_chk' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
  218 |       strncpy(buf + cont, key, key_len);
      |       ^
In function '_format_value_name_with_prefix',
    inlined from '_get_value_from_message.constprop.isra' at /source/modules/systemd-journal/journal-reader.c:243:3:
.../modules/systemd-journal/journal-reader.c:211:15: note: length computed here
  211 |     key_len = strlen(key);
      |               ^~~~~~~~~~~

This wasn't an actual issue as we were explicitly terminating the string
with NUL in this case, so missing the NUL character was actually expected.

Signed-off-by: Balazs Scheidler <[email protected]>
@MrAnno MrAnno merged commit 33ce5fc into axoflow:main Jan 14, 2025
22 checks passed
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.

2 participants