Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin clear errno before strto(u)l() if we're going to tes...
details: https://anonhg.NetBSD.org/src/rev/20c09a8d4ff5
branches: trunk
changeset: 545937:20c09a8d4ff5
user: lukem <lukem%NetBSD.org@localhost>
date: Fri Apr 18 03:21:00 2003 +0000
description:
clear errno before strto(u)l() if we're going to test it for ERANGE afterwards
diffstat:
usr.bin/gcore/gcore.c | 8 +++++---
usr.bin/head/head.c | 5 +++--
usr.bin/netstat/main.c | 5 +++--
usr.bin/renice/renice.c | 5 +++--
usr.bin/shuffle/shuffle.c | 8 +++++---
usr.bin/xlint/lint1/main1.c | 9 ++++++---
6 files changed, 25 insertions(+), 15 deletions(-)
diffs (168 lines):
diff -r 577c9502b6ed -r 20c09a8d4ff5 usr.bin/gcore/gcore.c
--- a/usr.bin/gcore/gcore.c Fri Apr 18 01:31:34 2003 +0000
+++ b/usr.bin/gcore/gcore.c Fri Apr 18 03:21:00 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gcore.c,v 1.5 2003/01/23 18:18:49 jdolecek Exp $ */
+/* $NetBSD: gcore.c,v 1.6 2003/04/18 03:21:00 lukem Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: gcore.c,v 1.5 2003/01/23 18:18:49 jdolecek Exp $");
+__RCSID("$NetBSD: gcore.c,v 1.6 2003/04/18 03:21:00 lukem Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -83,8 +83,10 @@
for (c = optind; c < argc; c++) {
char *ep;
- long lval = strtol(argv[c], &ep, 0);
+ long lval;
+ errno = 0;
+ lval = strtol(argv[c], &ep, 0);
if (argv[c] == '\0' || *ep)
errx(1, "`%s' is not a number.", argv[c]);
if (errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))
diff -r 577c9502b6ed -r 20c09a8d4ff5 usr.bin/head/head.c
--- a/usr.bin/head/head.c Fri Apr 18 01:31:34 2003 +0000
+++ b/usr.bin/head/head.c Fri Apr 18 03:21:00 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: head.c,v 1.14 2001/02/19 23:03:47 cgd Exp $ */
+/* $NetBSD: head.c,v 1.15 2003/04/18 03:21:01 lukem Exp $ */
/*
* Copyright (c) 1980, 1987, 1992, 1993
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)head.c 8.2 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: head.c,v 1.14 2001/02/19 23:03:47 cgd Exp $");
+__RCSID("$NetBSD: head.c,v 1.15 2003/04/18 03:21:01 lukem Exp $");
#endif
#endif /* not lint */
@@ -89,6 +89,7 @@
while ((ch = getopt(argc, argv, "n:")) != -1)
switch(ch) {
case 'n':
+ errno = 0;
linecnt = strtol(optarg, &ep, 10);
if ((linecnt == LONG_MIN || linecnt == LONG_MAX) &&
errno == ERANGE)
diff -r 577c9502b6ed -r 20c09a8d4ff5 usr.bin/netstat/main.c
--- a/usr.bin/netstat/main.c Fri Apr 18 01:31:34 2003 +0000
+++ b/usr.bin/netstat/main.c Fri Apr 18 03:21:00 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.40 2003/02/26 06:31:21 matt Exp $ */
+/* $NetBSD: main.c,v 1.41 2003/04/18 03:21:01 lukem Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "from: @(#)main.c 8.4 (Berkeley) 3/1/94";
#else
-__RCSID("$NetBSD: main.c,v 1.40 2003/02/26 06:31:21 matt Exp $");
+__RCSID("$NetBSD: main.c,v 1.41 2003/04/18 03:21:01 lukem Exp $");
#endif
#endif /* not lint */
@@ -450,6 +450,7 @@
numeric_addr = numeric_port = 1;
break;
case 'P':
+ errno = 0;
pcbaddr = strtoul(optarg, &cp, 16);
if (*cp != '\0' || errno == ERANGE)
errx(1, "invalid PCB address %s",
diff -r 577c9502b6ed -r 20c09a8d4ff5 usr.bin/renice/renice.c
--- a/usr.bin/renice/renice.c Fri Apr 18 01:31:34 2003 +0000
+++ b/usr.bin/renice/renice.c Fri Apr 18 03:21:00 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: renice.c,v 1.11 2001/09/01 01:59:42 simonb Exp $ */
+/* $NetBSD: renice.c,v 1.12 2003/04/18 03:21:01 lukem Exp $ */
/*
* Copyright (c) 1983, 1989, 1993
@@ -41,7 +41,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)renice.c 8.1 (Berkeley) 6/9/93";*/
-__RCSID("$NetBSD: renice.c,v 1.11 2001/09/01 01:59:42 simonb Exp $");
+__RCSID("$NetBSD: renice.c,v 1.12 2003/04/18 03:21:01 lukem Exp $");
#endif /* not lint */
#include <sys/resource.h>
@@ -123,6 +123,7 @@
long v;
char *ep;
+ errno = 0;
v = strtol(str, &ep, NULL);
if (*ep) {
diff -r 577c9502b6ed -r 20c09a8d4ff5 usr.bin/shuffle/shuffle.c
--- a/usr.bin/shuffle/shuffle.c Fri Apr 18 01:31:34 2003 +0000
+++ b/usr.bin/shuffle/shuffle.c Fri Apr 18 03:21:00 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: shuffle.c,v 1.11 2001/09/01 02:17:29 simonb Exp $ */
+/* $NetBSD: shuffle.c,v 1.12 2003/04/18 03:21:02 lukem Exp $ */
/*
* Copyright (c) 1998
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: shuffle.c,v 1.11 2001/09/01 02:17:29 simonb Exp $");
+__RCSID("$NetBSD: shuffle.c,v 1.12 2003/04/18 03:21:02 lukem Exp $");
#endif /* not lint */
#include <sys/time.h>
@@ -183,8 +183,10 @@
get_number(const char *str, int ch)
{
char *estr;
- long number = strtol(str, &estr, 0);
+ long number;
+ errno = 0;
+ number = strtol(str, &estr, 0);
if ((number == LONG_MIN || number == LONG_MAX) && errno == ERANGE)
err(1, "bad -%c argument `%s'", ch, str);
if (*estr)
diff -r 577c9502b6ed -r 20c09a8d4ff5 usr.bin/xlint/lint1/main1.c
--- a/usr.bin/xlint/lint1/main1.c Fri Apr 18 01:31:34 2003 +0000
+++ b/usr.bin/xlint/lint1/main1.c Fri Apr 18 03:21:00 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main1.c,v 1.13 2002/10/21 21:14:53 christos Exp $ */
+/* $NetBSD: main1.c,v 1.14 2003/04/18 03:21:02 lukem Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: main1.c,v 1.13 2002/10/21 21:14:53 christos Exp $");
+__RCSID("$NetBSD: main1.c,v 1.14 2003/04/18 03:21:02 lukem Exp $");
#endif
#include <sys/types.h>
@@ -157,7 +157,10 @@
for (ptr = strtok(optarg, ","); ptr;
ptr = strtok(NULL, ",")) {
char *eptr;
- long msg = strtol(ptr, &eptr, 0);
+ long msg;
+
+ errno = 0;
+ msg = strtol(ptr, &eptr, 0);
if ((msg == LONG_MIN || msg == LONG_MAX) &&
errno == ERANGE)
err(1, "invalid error message id '%s'",
Home |
Main Index |
Thread Index |
Old Index