Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/tip Remove broken snprintf usage (noted in PR 47976)...



details:   https://anonhg.NetBSD.org/src/rev/a10c52130108
branches:  trunk
changeset: 331022:a10c52130108
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sun Jul 27 04:32:23 2014 +0000

description:
Remove broken snprintf usage (noted in PR 47976) and replace with
something simpler.

diffstat:

 usr.bin/tip/cu.c  |  13 +++++++------
 usr.bin/tip/tip.c |  11 ++++++-----
 2 files changed, 13 insertions(+), 11 deletions(-)

diffs (94 lines):

diff -r 9674654ab339 -r a10c52130108 usr.bin/tip/cu.c
--- a/usr.bin/tip/cu.c  Sun Jul 27 04:26:23 2014 +0000
+++ b/usr.bin/tip/cu.c  Sun Jul 27 04:32:23 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cu.c,v 1.21 2011/09/06 18:33:01 joerg Exp $    */
+/*     $NetBSD: cu.c,v 1.22 2014/07/27 04:32:23 dholland Exp $ */
 
 /*
  * Copyright (c) 1983, 1993
@@ -36,7 +36,7 @@
 #if 0
 static char sccsid[] = "@(#)cu.c       8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: cu.c,v 1.21 2011/09/06 18:33:01 joerg Exp $");
+__RCSID("$NetBSD: cu.c,v 1.22 2014/07/27 04:32:23 dholland Exp $");
 #endif /* not lint */
 
 #include "tip.h"
@@ -55,7 +55,8 @@
        int flow = -1;          /* -1 is "tandem" ^S/^Q */
        static int helpme = 0, nostop = 0;
        char useresc = '~';
-       static char sbuf[12], brbuf[16];
+       static char sbuf[12];
+       int cmdlineBR;
        extern char *optarg;
        extern int optind;
 
@@ -80,6 +81,7 @@
        CU = NULL;
        DV = NULL;
        BR = DEFBR;
+       cmdlineBR = 0;
 
        while((c = getopt_long(argc, argv,
            "E:F:P:a:p:c:l:s:hefot0123456789", longopts, NULL)) != -1) {
@@ -159,9 +161,8 @@
                        break;
                case '0': case '1': case '2': case '3': case '4':
                case '5': case '6': case '7': case '8': case '9':
-                       (void)snprintf(brbuf, sizeof(brbuf) -1, "%s%c",
-                                brbuf, c);
-                       BR = atoi(brbuf);
+                       cmdlineBR = cmdlineBR * 10 + (c - '0');
+                       BR = cmdlineBR;
                        break;
                default:
                        if (nostop == 0)
diff -r 9674654ab339 -r a10c52130108 usr.bin/tip/tip.c
--- a/usr.bin/tip/tip.c Sun Jul 27 04:26:23 2014 +0000
+++ b/usr.bin/tip/tip.c Sun Jul 27 04:32:23 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tip.c,v 1.54 2014/07/12 05:28:07 mlelstv Exp $ */
+/*     $NetBSD: tip.c,v 1.55 2014/07/27 04:32:23 dholland Exp $        */
 
 /*
  * Copyright (c) 1983, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)tip.c      8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: tip.c,v 1.54 2014/07/12 05:28:07 mlelstv Exp $");
+__RCSID("$NetBSD: tip.c,v 1.55 2014/07/27 04:32:23 dholland Exp $");
 #endif /* not lint */
 
 /*
@@ -73,7 +73,7 @@
        char *p;
        const char *q;
        char sbuf[12];
-       static char brbuf[16];
+       int cmdlineBR;
        int fcarg;
 
        setprogname(argv[0]);
@@ -95,6 +95,7 @@
                exit(1);
        }
 
+       cmdlineBR = 0;
        while((c = getopt(argc, argv, "v0123456789")) != -1) {
                switch(c) {
 
@@ -104,8 +105,8 @@
 
                case '0': case '1': case '2': case '3': case '4':
                case '5': case '6': case '7': case '8': case '9':
-                       (void)snprintf(brbuf, sizeof(brbuf) -1, "%s%c", brbuf, c);
-                       BR = atoi(brbuf);
+                       cmdlineBR = cmdlineBR * 10 + (c - '0');
+                       BR = cmdlineBR;
                        break;
 
                default:



Home | Main Index | Thread Index | Old Index