jsoncat icon indicating copy to clipboard operation
jsoncat copied to clipboard

Warnings on Fedora 30

Open dioni21 opened this issue 6 years ago • 1 comments

src/parsing.c: In function ‘parse_object_close’:
src/parsing.c:80:5: warning: ‘strncat’ specified bound depends on the length of the source argument [-Wstringop-overflow=]
   80 |     strncat(value, to_append, strlen(to_append));
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CC gcc -c src/tokens.c -o lib/tokens.o  -O3 -g -std=gnu99  -fstack-protector-all -Wstack-protector -Wall -Wextra -pedantic 
src/tokens.c: In function ‘set_color’:
src/tokens.c:57:5: warning: ‘strncpy’ specified bound 6 equals destination size [-Wstringop-truncation]
   57 |     strncpy(token->color, color, COLOR_STR_SIZE);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘set_color’,
    inlined from ‘update_token’ at src/tokens.c:87:5:
src/tokens.c:57:5: warning: ‘strncpy’ specified bound 6 equals destination size [-Wstringop-truncation]
   57 |     strncpy(token->color, color, COLOR_STR_SIZE);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

dioni21 avatar Oct 16 '19 16:10 dioni21

Indeed, if you limit by array size, where will the \0 for string end be? :joy:

dioni21 avatar Oct 16 '19 16:10 dioni21