aboutsummaryrefslogtreecommitdiff
path: root/toys/other/makedevs.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-04-21 01:45:07 -0500
committerRob Landley <rob@landley.net>2015-04-21 01:45:07 -0500
commita829b89dbd324bcc005a5873fddf3faa81ea0536 (patch)
tree0057194d64cba2d7c5684155539bb0a4fdf428ba /toys/other/makedevs.c
parente5fb6a28ffb09782e4df08251956f42c48445147 (diff)
downloadtoybox-a829b89dbd324bcc005a5873fddf3faa81ea0536.tar.gz
Bugfix from Hyejin Kim (count=1 shouldn't change name), plus a bounds check.
Test is 'echo "AAA c 1 0 0 2 5 0 0 1" | makedevs' makes AAA not AAA0.
Diffstat (limited to 'toys/other/makedevs.c')
-rw-r--r--toys/other/makedevs.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/toys/other/makedevs.c b/toys/other/makedevs.c
index 0d20a57d..0f0a6615 100644
--- a/toys/other/makedevs.c
+++ b/toys/other/makedevs.c
@@ -84,8 +84,8 @@ void makedevs_main()
while (*node == '/') node++; // using relative path
for (i = 0; (!cnt && !i) || i < cnt; i++) {
- if (cnt) {
- snprintf(toybuf, sizeof(toybuf), "%s%u", node, st_val + i);
+ if (cnt>1) {
+ snprintf(toybuf, sizeof(toybuf), "%.999s%u", node, st_val + i);
ptr = toybuf;
} else ptr = node;