[hackers] [sbase] Check snprintf() return value || sin
 
commit 3ef662c988b01cb6be993f4cb0cd749a7e20105b
Author: sin <sin_AT_2f30.org>
Date:   Thu Jan 23 20:05:01 2014 +0000
    Check snprintf() return value
diff --git a/du.c b/du.c
index 525ed9b..e250e0c 100644
--- a/du.c
+++ b/du.c
_AT_@ -137,11 +137,13 @@ du(const char *path)
                 m = nblks(&st);
                 n += m;
                 if (aflag && !sflag) {
-			if (S_ISLNK(st.st_mode))
-				snprintf(file, sizeof(file), "%s/%s",
-					 cwd, dent->d_name);
-			else
+			if (S_ISLNK(st.st_mode)) {
+				if (snprintf(file, sizeof(file), "%s/%s",
+					     cwd, dent->d_name) >= sizeof(file))
+					enprintf(EXIT_FAILURE, "path too long
");
+			} else {
                                 realpath(dent->d_name, file);
+			}
                         print(m, file);
                 }
         }
Received on Thu Jan 23 2014 - 22:17:19 CET
This archive was generated by hypermail 2.3.0
: Thu Jan 23 2014 - 22:24:10 CET