From a829b89dbd324bcc005a5873fddf3faa81ea0536 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 21 Apr 2015 01:45:07 -0500 Subject: 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. --- toys/other/makedevs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'toys/other/makedevs.c') 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; -- cgit v1.2.3