The source code line content, saved to improve error reporting, might get truncated, as the current Bison source buffer is 8192 bytes long and only 254 bytes (plus NUL-terminator) are reserved. As the saved string is only used for improving error reports and source lines longer than 254 character are quite uncommon, simply silence the GCC warning. In file included from /usr/include/string.h:519, from lex.yy.c:20: In function ‘strncpy’, inlined from ‘yylex’ at policy_scan.l:63:7: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:91:10: warning: ‘__builtin_strncpy’ output may be truncated copying 255 bytes from a string of length 8190 [-Wstringop-truncation] 91 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx> --- checkpolicy/policy_scan.l | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/checkpolicy/policy_scan.l b/checkpolicy/policy_scan.l index ef9f1899..9fefea7b 100644 --- a/checkpolicy/policy_scan.l +++ b/checkpolicy/policy_scan.l @@ -60,7 +60,14 @@ hexval [0-9A-Fa-f] %% \n.* { +#if defined(__GNUC__) && __GNUC__ >= 8 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" +#endif strncpy(linebuf[lno], yytext+1, 255); +#if defined(__GNUC__) && __GNUC__ >= 8 +#pragma GCC diagnostic pop +#endif linebuf[lno][254] = 0; lno = 1 - lno; policydb_lineno++; -- 2.33.1