Module Name: src Committed By: dholland Date: Sun Jul 27 04:32:23 UTC 2014
Modified Files: src/usr.bin/tip: cu.c tip.c Log Message: Remove broken snprintf usage (noted in PR 47976) and replace with something simpler. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.bin/tip/cu.c cvs rdiff -u -r1.54 -r1.55 src/usr.bin/tip/tip.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/tip/cu.c diff -u src/usr.bin/tip/cu.c:1.21 src/usr.bin/tip/cu.c:1.22 --- src/usr.bin/tip/cu.c:1.21 Tue Sep 6 18:33:01 2011 +++ src/usr.bin/tip/cu.c Sun Jul 27 04:32:23 2014 @@ -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) Index: src/usr.bin/tip/tip.c diff -u src/usr.bin/tip/tip.c:1.54 src/usr.bin/tip/tip.c:1.55 --- src/usr.bin/tip/tip.c:1.54 Sat Jul 12 05:28:07 2014 +++ src/usr.bin/tip/tip.c Sun Jul 27 04:32:23 2014 @@ -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, 19 #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: