clients: Silence wstringop-truncation warning 52/280852/1
authorSeunghun Lee <shiin.lee@samsung.com>
Tue, 6 Sep 2022 01:18:42 +0000 (10:18 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Tue, 6 Sep 2022 01:57:03 +0000 (10:57 +0900)
Change-Id: Ia90870b6b2b21832f7f440cd141c368a314a86b3

clients/simple-shm-shell.c

index e0bdcb4..cbcdf97 100644 (file)
@@ -100,8 +100,14 @@ _create_anonymous_file (off_t size)
                return -1;
        }
 
+       if (strlen(path) + strlen(template) > (PATH_MAX - 1)) {
+               errno = ENAMETOOLONG;
+               return -1;
+       }
+
        strncpy(name, path, PATH_MAX);
-       strncat(name, template, PATH_MAX);
+       name[PATH_MAX - 1] = '\0';
+       strncat(name, template, strlen(template));
 
        fd = mkstemp(name);
        if (fd < 0)