Module Name:    src
Committed By:   dholland
Date:           Sun Mar 23 05:26:23 UTC 2014

Modified Files:
        src/sbin/resize_lfs: resize_lfs.c

Log Message:
don't use sprintf


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sbin/resize_lfs/resize_lfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/resize_lfs/resize_lfs.c
diff -u src/sbin/resize_lfs/resize_lfs.c:1.7 src/sbin/resize_lfs/resize_lfs.c:1.8
--- src/sbin/resize_lfs/resize_lfs.c:1.7	Wed Jun 19 01:07:55 2013
+++ src/sbin/resize_lfs/resize_lfs.c	Sun Mar 23 05:26:23 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: resize_lfs.c,v 1.7 2013/06/19 01:07:55 christos Exp $	*/
+/*	$NetBSD: resize_lfs.c,v 1.8 2014/03/23 05:26:23 dholland Exp $	*/
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -60,6 +60,7 @@ int
 main(int argc, char **argv)
 {
 	char *rdev, *fsname, buf[LFS_SBPAD];
+	size_t rdevlen;
 	daddr_t newsize, newnsegs;
 	int devfd, rootfd;
 	int ch, i, verbose;
@@ -95,8 +96,9 @@ main(int argc, char **argv)
 	 */
 	if (statvfs(fsname, &vfs) < 0)
 		err(1, "%s", fsname);
-	rdev = (char *)malloc(strlen(vfs.f_mntfromname + 2));
-	sprintf(rdev, "/dev/r%s", vfs.f_mntfromname + 5);
+	rdevlen = strlen(vfs.f_mntfromname) + 2;
+	rdev = malloc(rdevlen);
+	snprintf(rdev, rdevlen, "/dev/r%s", vfs.f_mntfromname + 5);
 	devfd = open(rdev, O_RDONLY);
 	if (devfd < 0)
 		err(1, "open raw device");

Reply via email to