diff options
author | lostd <lostd@2f30.org> | 2014-10-08 15:14:11 +0300 |
---|---|---|
committer | lostd <lostd@2f30.org> | 2014-10-08 15:14:11 +0300 |
commit | 4b56e4a122c9c16d00f459a992496423e2abce63 (patch) | |
tree | 3be0aeb5ed613c47299024a223993c6aed111c03 | |
parent | b6c43f66a9adeb7e3f19d6cffc9c14abf60dd855 (diff) | |
download | nnn-4b56e4a122c9c16d00f459a992496423e2abce63.tar.gz |
Avoid sprintf(3) and use snprintf(3) instead
-rw-r--r-- | noice.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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); |