clear errno before strto(u)l() if we're going to test it for ERANGE afterwards

This commit is contained in:
lukem 2003-04-17 04:01:56 +00:00
parent c6af0a620d
commit 85828b646a
2 changed files with 6 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: fsirand.c,v 1.20 2003/04/02 10:39:29 fvdl Exp $ */
/* $NetBSD: fsirand.c,v 1.21 2003/04/17 04:01:56 lukem Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: fsirand.c,v 1.20 2003/04/02 10:39:29 fvdl Exp $");
__RCSID("$NetBSD: fsirand.c,v 1.21 2003/04/17 04:01:56 lukem Exp $");
#endif /* lint */
#include <sys/param.h>
@ -256,6 +256,7 @@ main(int argc, char *argv[])
pflag++;
break;
case 'x':
errno = 0;
xorval = strtol(optarg, &ep, 0);
if ((xorval == LONG_MIN || xorval == LONG_MAX) &&
errno == ERANGE)

View File

@ -1,4 +1,4 @@
/* $NetBSD: mknod.c,v 1.24 2001/10/08 04:45:29 lukem Exp $ */
/* $NetBSD: mknod.c,v 1.25 2003/04/17 04:01:57 lukem Exp $ */
/*-
* Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#include <sys/cdefs.h>
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved.\n");
__RCSID("$NetBSD: mknod.c,v 1.24 2001/10/08 04:45:29 lukem Exp $");
__RCSID("$NetBSD: mknod.c,v 1.25 2003/04/17 04:01:57 lukem Exp $");
#endif /* not lint */
#include <sys/types.h>
@ -133,6 +133,7 @@ main(int argc, char **argv)
}
for (n = 0; n < argc; n++) {
errno = 0;
numbers[n] = strtoul(argv[n], &p, 0);
if ((p && *p != '\0') ||
(numbers[n] == ULONG_MAX && errno == ERANGE))