summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEitan Adler <eadler@FreeBSD.org>2012-12-05 13:56:52 +0000
committerEitan Adler <eadler@FreeBSD.org>2012-12-05 13:56:52 +0000
commit3d0fb3a57e72d37356b6a765070b3a2289837f77 (patch)
tree8673dd044ae27985a865d8b2b9ab4d03020bfe03
parent3ed3b62bd35ad2bc1ec73c566c5b1c49b6ba8bc1 (diff)
downloadpw-darwin-3d0fb3a57e72d37356b6a765070b3a2289837f77.tar.gz
pw-darwin-3d0fb3a57e72d37356b6a765070b3a2289837f77.tar.zst
pw-darwin-3d0fb3a57e72d37356b6a765070b3a2289837f77.zip
Avoid overflowing the file buffer
Submitted by: db Approved by: cperciva MFC after: 2 weeks
-rw-r--r--pw/rm_r.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/pw/rm_r.c b/pw/rm_r.c
index 4ad590b..797ca9d 100644
--- a/pw/rm_r.c
+++ b/pw/rm_r.c
@@ -52,7 +52,7 @@ rm_r(char const * dir, uid_t uid)
while ((e = readdir(d)) != NULL) {
if (strcmp(e->d_name, ".") != 0 && strcmp(e->d_name, "..") != 0) {
- sprintf(file, "%s/%s", dir, e->d_name);
+ snprintf(file, sizeof(file), "%s/%s", dir, e->d_name);
if (lstat(file, &st) == 0) { /* Need symlinks, not
* linked file */
if (S_ISDIR(st.st_mode)) /* Directory - recurse */