From 8f23b0b3fa61cb112a974a711fe3c424482fe11d Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Tue, 14 Jun 2005 06:42:13 +0000 Subject: Replace sprintf calls with snprintf To quiet diet-libc Signed-off-by: Neil Brown --- mdopen.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mdopen.c') diff --git a/mdopen.c b/mdopen.c index 9309fbd2..81cf725b 100644 --- a/mdopen.c +++ b/mdopen.c @@ -42,7 +42,8 @@ void make_parts(char *dev, int cnt) struct stat stb; int major, minor; int i; - char *name = malloc(strlen(dev) + 20); + int nlen = strlen(dev) + 20; + char *name = malloc(nlen); int dig = isdigit(dev[strlen(dev)-1]); if (stat(dev, &stb)!= 0) @@ -53,7 +54,7 @@ void make_parts(char *dev, int cnt) minor = minor(stb.st_rdev); for (i=1; i <= cnt ; i++) { struct stat stb2; - sprintf(name, "%s%s%d", dev, dig?"p":"", i); + snprintf(name, nlen, "%s%s%d", dev, dig?"p":"", i); if (stat(name, &stb2)==0) { if (!S_ISBLK(stb2.st_mode)) continue; -- cgit v1.2.3