Check snprintf() return value
This commit is contained in:
parent
cc2d762798
commit
3ef662c988
10
du.c
10
du.c
@ -137,11 +137,13 @@ du(const char *path)
|
|||||||
m = nblks(&st);
|
m = nblks(&st);
|
||||||
n += m;
|
n += m;
|
||||||
if (aflag && !sflag) {
|
if (aflag && !sflag) {
|
||||||
if (S_ISLNK(st.st_mode))
|
if (S_ISLNK(st.st_mode)) {
|
||||||
snprintf(file, sizeof(file), "%s/%s",
|
if (snprintf(file, sizeof(file), "%s/%s",
|
||||||
cwd, dent->d_name);
|
cwd, dent->d_name) >= sizeof(file))
|
||||||
else
|
enprintf(EXIT_FAILURE, "path too long\n");
|
||||||
|
} else {
|
||||||
realpath(dent->d_name, file);
|
realpath(dent->d_name, file);
|
||||||
|
}
|
||||||
print(m, file);
|
print(m, file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user