[PATCH v2 1/1] makedevs: set path size to match linux

Matt Weber matthew.weber at rockwellcollins.com
Wed Jul 5 18:35:49 UTC 2017


From: Jared Bents <jared.bents at rockwellcollins.com>

Update to increase the pathname limit to the
linux limit of 4096 characters.

Similar patch:
https://patchwork.openembedded.org/patch/131475/

Signed-off-by: Jared Bents <jared.bents at rockwellcollins.com>
Signed-off-by: Matt Weber <matthew.weber at rockwellcollins.com>
---

Changes
v1 -> v2
[Baruch Siach
 - Use of PATH_MAX instead of just increasing value to 4096

---
 miscutils/makedevs.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c
index 9e7ca34..d29b479 100644
--- a/miscutils/makedevs.c
+++ b/miscutils/makedevs.c
@@ -104,6 +104,9 @@
 
 #include "libbb.h"
 
+#define STRINGIFY(x) STRINGIFY2(x)
+#define STRINGIFY2(x) #x
+
 #if ENABLE_FEATURE_MAKEDEVS_LEAF
 /*
 makedevs NAME TYPE MAJOR MINOR FIRST LAST [s]
@@ -208,7 +211,7 @@ int makedevs_main(int argc UNUSED_PARAM, char **argv)
 		unsigned count = 0;
 		unsigned increment = 0;
 		unsigned start = 0;
-		char name[41];
+		char name[PATH_MAX+1];
 		char user[41];
 		char group[41];
 		char *full_name = name;
@@ -217,7 +220,7 @@ int makedevs_main(int argc UNUSED_PARAM, char **argv)
 
 		linenum = parser->lineno;
 
-		if ((2 > sscanf(line, "%40s %c %o %40s %40s %u %u %u %u %u",
+		if ((2 > sscanf(line, "%" STRINGIFY(PATH_MAX) "s %c %o %40s %40s %u %u %u %u %u",
 					name, &type, &mode, user, group,
 					&major, &minor, &start, &increment, &count))
 		 || ((unsigned)(major | minor | start | count | increment) > 255)
-- 
1.9.1



More information about the busybox mailing list