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 compiler error #27

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

Conversation

tbarbette
Copy link
Contributor

Recent GCC (9.3 at least) got smarter and sees that strncopy should not
be used with the length of the string, and memcpy should be used instead. The
error:

In function strncpy,
inlined from LoadConfig at ../common/applib.c:127:4:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: __builtin_strncpy output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../common/applib.c: In function LoadConfig:
../common/applib.c:124:15: note: length computed here
124 | if ((len = strlen(p)) > CONF_VALUE_LEN)

Recent GCC (9.3 at least) got smarter and sees that strncopy should not
be used with its own length, and memcpy should be used instead. The
error:

In function strncpy,
    inlined from LoadConfig at ../common/applib.c:127:4:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: __builtin_strncpy output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../common/applib.c: In function LoadConfig:
../common/applib.c:124:15: note: length computed here
  124 |    if ((len = strlen(p)) > CONF_VALUE_LEN)
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

1 participant