cgmnlm

colorful gemini line mode browser
git clone https://git.clttr.info/cgmnlm.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit ec88f4558c48b3eece906143867dfba6d81e5e49
parent ab66dd2be92931bef04cbccdb3aa008615bd8eba
Author: William Casarin <jb55@jb55.com>
Date:   Sat,  7 Nov 2020 14:58:32 -0800

gmnlm: fix a few strncpy compile errors on gcc 9.3

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 <jb55@jb55.com>

Diffstat:
Msrc/gmnlm.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 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",