imlib2_conv.c: Fix gcc8 warning

imlib2_conv.c: In function ‘main’:
imlib2_conv.c:64:14: error: ‘strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
              strncpy(p, dot, (strlen(dot) < 9) ? strlen(dot) : 8);
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
imlib2_conv.c:64:31: note: length computed here
              strncpy(p, dot, (strlen(dot) < 9) ? strlen(dot) : 8);
                               ^~~~~~~~~~~
This commit is contained in:
Kim Woelders 2018-03-10 19:48:51 +01:00
parent 4d6ff056ef
commit d0da3117e9
1 changed files with 2 additions and 4 deletions

View File

@ -59,11 +59,9 @@ main(int argc, char **argv)
char *p, *q;
/* max length of 8 for format name. seems reasonable. */
q = p = malloc(9);
memset(p, 0, 8);
strncpy(p, dot, (strlen(dot) < 9) ? strlen(dot) : 8);
p = strndup(dot, 8);
/* Imlib2 only recognizes lowercase formats. convert it. */
for (q[8] = 0; *q; q++)
for (q = p; *q; q++)
*q = tolower(*q);
imlib_image_set_format(p);
free(p);