checkpolicy: ignore possible string truncation
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@googlemail.com>
This commit is contained in:
parent
cee0fe36a7
commit
8a8275a5ac
1 changed files with 7 additions and 0 deletions
|
@ -60,7 +60,14 @@ hexval [0-9A-Fa-f]
|
||||||
|
|
||||||
%%
|
%%
|
||||||
\n.* {
|
\n.* {
|
||||||
|
#if defined(__GNUC__) && __GNUC__ >= 8
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wstringop-truncation"
|
||||||
|
#endif
|
||||||
strncpy(linebuf[lno], yytext+1, 255);
|
strncpy(linebuf[lno], yytext+1, 255);
|
||||||
|
#if defined(__GNUC__) && __GNUC__ >= 8
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
linebuf[lno][254] = 0;
|
linebuf[lno][254] = 0;
|
||||||
lno = 1 - lno;
|
lno = 1 - lno;
|
||||||
policydb_lineno++;
|
policydb_lineno++;
|
||||||
|
|
Loading…
Reference in a new issue