From ec88f4558c48b3eece906143867dfba6d81e5e49 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Sat, 7 Nov 2020 14:58:32 -0800 Subject: [PATCH] gmnlm: fix a few strncpy compile errors on gcc 9.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In file included from .../include/string.h:495, from src/gmnlm.c:11: In function ‘strncpy’, inlined from ‘do_prompts’ at src/gmnlm.c:627:3: ...glibc-2.31-dev/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 1024 equals destination size [-Werror=stringop-truncation] return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In function ‘strncpy’, inlined from ‘do_prompts’ at src/gmnlm.c:612:3: ...glibc-2.31-dev/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 1024 equals destination size [-Werror=stringop-truncation] return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: William Casarin --- src/gmnlm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gmnlm.c b/src/gmnlm.c index da43dbe..2eb906e 100644 --- a/src/gmnlm.c +++ b/src/gmnlm.c @@ -609,7 +609,7 @@ do_prompts(const char *prompt, struct browser *browser) if (in[1] != '\0' && !isspace(in[1])) break; struct gemini_response resp; char url[1024] = {0}; - strncpy(&url[0], browser->plain_url, sizeof(url)); + strncpy(&url[0], browser->plain_url, sizeof(url)-1); // XXX: may affect history, do we care? enum gemini_result res = do_requests(browser, &resp); if (res != GEMINI_OK) { @@ -624,7 +624,7 @@ do_prompts(const char *prompt, struct browser *browser) result = PROMPT_AGAIN; goto exit; case '|': - strncpy(&url[0], browser->plain_url, sizeof(url)); + strncpy(&url[0], browser->plain_url, sizeof(url)-1); res = do_requests(browser, &resp); if (res != GEMINI_OK) { fprintf(stderr, "Error: %s\n",