kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=d0da3117e9b2a1599fa08fd74f8ca4bc9be42fc8

commit d0da3117e9b2a1599fa08fd74f8ca4bc9be42fc8
Author: Kim Woelders <k...@woelders.dk>
Date:   Sat Mar 10 19:48:51 2018 +0100

    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);
                                   ^~~~~~~~~~~
---
 src/bin/imlib2_conv.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/bin/imlib2_conv.c b/src/bin/imlib2_conv.c
index 975a4e0..0148079 100644
--- a/src/bin/imlib2_conv.c
+++ b/src/bin/imlib2_conv.c
@@ -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);

-- 


Reply via email to