1
0
mirror of https://git.sr.ht/~sircmpwn/gmni synced 2024-11-23 04:51:59 +01:00

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>
This commit is contained in:
William Casarin 2020-11-07 14:58:32 -08:00 committed by Drew DeVault
parent ab66dd2be9
commit ec88f4558c

@ -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",