gcc 8.1 on DragonFlyBSD is warning below. It seems to be saying max copy length shouldn't depend on the input string itself, so change the length argument to "sizeof(lexer_input_buffer)-3" without strlen() involved, followed by explicit \0 termination at the end of source string length or at "sizeof(lexer_input_buffer)-3". (-3 comes from what this function has been using.) -- CC y.tab.o In function 'setup_to_parse_string', inlined from 'evaluate_arithmetic_expression' at y.tab.c:317:2: y.tab.c:305:2: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-overflow=] strncpy(lexer_input_buffer, string, len); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ y.tab.c: In function 'evaluate_arithmetic_expression': y.tab.c:301:8: note: length computed here len = strlen(string); ^~~~~~~~~~~~~~ Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@xxxxxxxxx> --- exp/expression-parser.y | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/exp/expression-parser.y b/exp/expression-parser.y index 04a6e07..29e2bcf 100644 --- a/exp/expression-parser.y +++ b/exp/expression-parser.y @@ -208,7 +208,7 @@ static void setup_to_parse_string(const char *string) if (len > sizeof(lexer_input_buffer) - 3) len = sizeof(lexer_input_buffer) - 3; - strncpy(lexer_input_buffer, string, len); + strncpy(lexer_input_buffer, string, sizeof(lexer_input_buffer)-3); lexer_input_buffer[len] = '\0'; lexer_input_buffer[len + 1] = '\0'; /* lex/yacc want string double null terminated! */ lexer_read_offset = 0; -- 1.7.1