]> Sergey Matveev's repositories - nnn.git/commitdiff
Avoid sprintf(3) and use snprintf(3) instead
authorlostd <lostd@2f30.org>
Wed, 8 Oct 2014 12:14:11 +0000 (15:14 +0300)
committerlostd <lostd@2f30.org>
Wed, 8 Oct 2014 12:14:11 +0000 (15:14 +0300)
noice.c

diff --git a/noice.c b/noice.c
index 656ec8f65fb41e7ada3a9d61152a1513241d9cfb..eed91895fec8fea7c31bb5d7f8a652687b2269f2 100644 (file)
--- a/noice.c
+++ b/noice.c
@@ -347,6 +347,7 @@ nochange:
                }
                if (ret == 3) {
                        char *pathnew, *pathtmp;
+                       size_t pathsiz;
                        char *name;
                        u_int8_t type;
                        char *bin;
@@ -360,9 +361,9 @@ nochange:
                        name = dents[cur]->d_name;
                        type = dents[cur]->d_type;
 
-                       pathnew = malloc(strlen(path) + 1
-                           + strlen(name) + 1);
-                       sprintf(pathnew, "%s/%s", path, name);
+                       pathsiz = strlen(path) + 1 + strlen(name) + 1;
+                       pathnew = malloc(pathsiz);
+                       snprintf(pathnew, pathsiz, "%s/%s", path, name);
 
                        DPRINTF_S(name);
                        DPRINTF_U(type);