Avoid sprintf(3) and use snprintf(3) instead

This commit is contained in:
lostd 2014-10-08 15:14:11 +03:00
parent b6c43f66a9
commit 4b56e4a122
1 changed files with 4 additions and 3 deletions

View File

@ -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);