Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src don't use sprintf



details:   https://anonhg.NetBSD.org/src/rev/cc64415e7a78
branches:  trunk
changeset: 328008:cc64415e7a78
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sun Mar 23 05:07:59 2014 +0000

description:
don't use sprintf

diffstat:

 bin/sh/histedit.c                  |  10 ++++++----
 sbin/amrctl/amrctl.c               |  15 +++++++++------
 sbin/newfs_sysvbfs/newfs_sysvbfs.c |   6 +++---
 3 files changed, 18 insertions(+), 13 deletions(-)

diffs (99 lines):

diff -r 7b3c41269205 -r cc64415e7a78 bin/sh/histedit.c
--- a/bin/sh/histedit.c Sun Mar 23 05:06:42 2014 +0000
+++ b/bin/sh/histedit.c Sun Mar 23 05:07:59 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: histedit.c,v 1.45 2012/03/20 18:42:29 matt Exp $       */
+/*     $NetBSD: histedit.c,v 1.46 2014/03/23 05:07:59 dholland Exp $   */
 
 /*-
  * Copyright (c) 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)histedit.c 8.2 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: histedit.c,v 1.45 2012/03/20 18:42:29 matt Exp $");
+__RCSID("$NetBSD: histedit.c,v 1.46 2014/03/23 05:07:59 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -432,10 +432,12 @@
        }
        if (editor) {
                char *editcmd;
+               size_t cmdlen;
 
                fclose(efp);
-               editcmd = stalloc(strlen(editor) + strlen(editfile) + 2);
-               sprintf(editcmd, "%s %s", editor, editfile);
+               cmdlen = strlen(editor) + strlen(editfile) + 2;
+               editcmd = stalloc(cmdlen);
+               snprintf(editcmd, cmdlen, "%s %s", editor, editfile);
                evalstring(editcmd, 0); /* XXX - should use no JC command */
                INTON;
                readcmdfile(editfile);  /* XXX - should read back - quick tst */
diff -r 7b3c41269205 -r cc64415e7a78 sbin/amrctl/amrctl.c
--- a/sbin/amrctl/amrctl.c      Sun Mar 23 05:06:42 2014 +0000
+++ b/sbin/amrctl/amrctl.c      Sun Mar 23 05:07:59 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: amrctl.c,v 1.9 2012/05/18 14:01:34 jakllsch Exp $      */
+/*     $NetBSD: amrctl.c,v 1.10 2014/03/23 05:09:56 dholland Exp $     */
 
 /*-
  * Copyright (c) 2002, Pierre David <Pierre.David%crc.u-strasbg.fr@localhost>
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: amrctl.c,v 1.9 2012/05/18 14:01:34 jakllsch Exp $");
+__RCSID("$NetBSD: amrctl.c,v 1.10 2014/03/23 05:09:56 dholland Exp $");
 #endif
 
 #include <stdio.h>
@@ -311,18 +311,21 @@
                                         */
                                        product = "HP NetRaid 3si";
                                }
-                               sprintf(firmware, "%c.%02d.%02d",
+                               snprintf(firmware, sizeof(firmware),
+                                       "%c.%02d.%02d",
                                        ae->ae_adapter.aa_firmware[2],
                                        ae->ae_adapter.aa_firmware[1],
                                        ae->ae_adapter.aa_firmware[0]);
-                               sprintf(bios, "%c.%02d.%02d",
+                               snprintf(bios, sizeof(bios),
+                                       "%c.%02d.%02d",
                                        ae->ae_adapter.aa_bios[2],
                                        ae->ae_adapter.aa_bios[1],
                                        ae->ae_adapter.aa_bios[0]);
                        } else {
-                               sprintf(firmware, "%.4s",
+                               snprintf(firmware, sizeof(firmware), "%.4s",
                                        ae->ae_adapter.aa_firmware);
-                               sprintf(bios, "%.4s", ae->ae_adapter.aa_bios);
+                               snprintf(bios, sizeof(bios), "%.4s",
+                                       ae->ae_adapter.aa_bios);
                        }
 
                        printf("Ioctl = %d (%s)\n", FIRMWARE_8LD, "8LD");
diff -r 7b3c41269205 -r cc64415e7a78 sbin/newfs_sysvbfs/newfs_sysvbfs.c
--- a/sbin/newfs_sysvbfs/newfs_sysvbfs.c        Sun Mar 23 05:06:42 2014 +0000
+++ b/sbin/newfs_sysvbfs/newfs_sysvbfs.c        Sun Mar 23 05:07:59 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: newfs_sysvbfs.c,v 1.8 2011/08/29 14:35:03 joerg Exp $  */
+/*     $NetBSD: newfs_sysvbfs.c,v 1.9 2014/03/23 05:10:56 dholland Exp $       */
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -220,10 +220,10 @@
        /* dirent table */
        memset(buf, 0, BFS_BSIZE);
        dirent->inode = BFS_ROOT_INODE;
-       sprintf(dirent->name, ".");
+       strcpy(dirent->name, ".");
        dirent++;
        dirent->inode = BFS_ROOT_INODE;
-       sprintf(dirent->name, "..");
+       strcpy(dirent->name, "..");
        if (write(fd, buf, BFS_BSIZE) < 0) {
                perror("write dirent");
                return -1;



Home | Main Index | Thread Index | Old Index