mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Avoid sprintf(3) and use snprintf(3) instead
This commit is contained in:
parent
b6c43f66a9
commit
4b56e4a122
7
noice.c
7
noice.c
|
@ -347,6 +347,7 @@ nochange:
|
||||||
}
|
}
|
||||||
if (ret == 3) {
|
if (ret == 3) {
|
||||||
char *pathnew, *pathtmp;
|
char *pathnew, *pathtmp;
|
||||||
|
size_t pathsiz;
|
||||||
char *name;
|
char *name;
|
||||||
u_int8_t type;
|
u_int8_t type;
|
||||||
char *bin;
|
char *bin;
|
||||||
|
@ -360,9 +361,9 @@ nochange:
|
||||||
name = dents[cur]->d_name;
|
name = dents[cur]->d_name;
|
||||||
type = dents[cur]->d_type;
|
type = dents[cur]->d_type;
|
||||||
|
|
||||||
pathnew = malloc(strlen(path) + 1
|
pathsiz = strlen(path) + 1 + strlen(name) + 1;
|
||||||
+ strlen(name) + 1);
|
pathnew = malloc(pathsiz);
|
||||||
sprintf(pathnew, "%s/%s", path, name);
|
snprintf(pathnew, pathsiz, "%s/%s", path, name);
|
||||||
|
|
||||||
DPRINTF_S(name);
|
DPRINTF_S(name);
|
||||||
DPRINTF_U(type);
|
DPRINTF_U(type);
|
||||||
|
|
Loading…
Reference in a new issue