summaryrefslogtreecommitdiff
path: root/usr.bin/tip
diff options
context:
space:
mode:
authordholland <dholland@NetBSD.org>2014-07-27 04:32:23 +0000
committerdholland <dholland@NetBSD.org>2014-07-27 04:32:23 +0000
commitd6f63ad7d0d282cdc965dc880a7f3ff1c5b03593 (patch)
treeaadcc9e4522421c90505561a05984d9b0172cee4 /usr.bin/tip
parent5cfb99f94189a2e4b1260adbc7b2f018c3ffd60e (diff)
Remove broken snprintf usage (noted in PR 47976) and replace with
something simpler.
Diffstat (limited to 'usr.bin/tip')
-rw-r--r--usr.bin/tip/cu.c13
-rw-r--r--usr.bin/tip/tip.c11
2 files changed, 13 insertions, 11 deletions
diff --git a/usr.bin/tip/cu.c b/usr.bin/tip/cu.c
index bc3dc0f448c..2d7d0b58468 100644
--- a/usr.bin/tip/cu.c
+++ b/usr.bin/tip/cu.c
@@ -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 @@ cumain(int argc, char *argv[])
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 @@ cumain(int argc, char *argv[])
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 @@ cumain(int argc, char *argv[])
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 --git a/usr.bin/tip/tip.c b/usr.bin/tip/tip.c
index cf3bbf9b1a8..d47430e138e 100644
--- a/usr.bin/tip/tip.c
+++ b/usr.bin/tip/tip.c
@@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\
#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 @@ main(int argc, char *argv[])
char *p;
const char *q;
char sbuf[12];
- static char brbuf[16];
+ int cmdlineBR;
int fcarg;
setprogname(argv[0]);
@@ -95,6 +95,7 @@ main(int argc, char *argv[])
exit(1);
}
+ cmdlineBR = 0;
while((c = getopt(argc, argv, "v0123456789")) != -1) {
switch(c) {
@@ -104,8 +105,8 @@ main(int argc, char *argv[])
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: