Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/tip check speed argument conversion (Thierry Laronde)



details:   https://anonhg.NetBSD.org/src/rev/947b28aa6bc4
branches:  trunk
changeset: 1002855:947b28aa6bc4
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Aug 18 14:16:02 2019 +0000

description:
check speed argument conversion (Thierry Laronde)

diffstat:

 usr.bin/tip/cu.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (45 lines):

diff -r 7d2e8686647c -r 947b28aa6bc4 usr.bin/tip/cu.c
--- a/usr.bin/tip/cu.c  Sun Aug 18 11:53:23 2019 +0000
+++ b/usr.bin/tip/cu.c  Sun Aug 18 14:16:02 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cu.c,v 1.23 2016/01/03 15:38:29 christos Exp $ */
+/*     $NetBSD: cu.c,v 1.24 2019/08/18 14:16:02 christos Exp $ */
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,12 +31,13 @@
 
 #include <sys/cdefs.h>
 #include <getopt.h>
+#include <inttypes.h>
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)cu.c       8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: cu.c,v 1.23 2016/01/03 15:38:29 christos Exp $");
+__RCSID("$NetBSD: cu.c,v 1.24 2019/08/18 14:16:02 christos Exp $");
 #endif /* not lint */
 
 #include "tip.h"
@@ -50,7 +51,7 @@
 void
 cumain(int argc, char *argv[])
 {
-       int c, i, phonearg = 0;
+       int c, i, phonearg = 0, e;
        int parity = 0;         /* 0 is no parity */
        int flow = -1;          /* -1 is "tandem" ^S/^Q */
        static int helpme = 0, nostop = 0;
@@ -140,7 +141,10 @@
                        useresc = -1;
                        break;
                case 's':
-                       BR = atoi(optarg);
+                       BR = (long)strtoi(optarg, NULL, 0, 1, LONG_MAX, &e);
+                       if (e)
+                               warnc(e, "Conversion of `%s' to a baud rate "
+                                   "failed, using %ld", optarg, BR);
                        break;
                case 'h':
                        HD = TRUE;



Home | Main Index | Thread Index | Old Index