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

This commit is contained in:
lukem 2003-04-17 02:41:21 +00:00
parent b7394dfe47
commit e7fa9814b3
2 changed files with 6 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: iteconfig.c,v 1.6 1997/10/17 09:54:34 lukem Exp $ */
/* $NetBSD: iteconfig.c,v 1.7 2003/04/17 02:41:21 lukem Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
* All rights reserved.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: iteconfig.c,v 1.6 1997/10/17 09:54:34 lukem Exp $");
__RCSID("$NetBSD: iteconfig.c,v 1.7 2003/04/17 02:41:21 lukem Exp $");
#endif
#include <sys/types.h>
@ -207,6 +207,7 @@ xstrtol(s)
{
long rv;
errno = 0;
rv = strtol(s, NULL, 0);
if (errno == ERANGE && (rv == LONG_MIN || rv == LONG_MAX))
err(1, "bad format: \"%s\"", s);

View File

@ -1,4 +1,4 @@
/* $NetBSD: mountd.c,v 1.82 2003/01/06 12:29:52 wiz Exp $ */
/* $NetBSD: mountd.c,v 1.83 2003/04/17 02:41:22 lukem Exp $ */
/*
* Copyright (c) 1989, 1993
@ -51,7 +51,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
#if 0
static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95";
#else
__RCSID("$NetBSD: mountd.c,v 1.82 2003/01/06 12:29:52 wiz Exp $");
__RCSID("$NetBSD: mountd.c,v 1.83 2003/04/17 02:41:22 lukem Exp $");
#endif
#endif /* not lint */
@ -2219,6 +2219,7 @@ get_net(cp, net, maskflg)
net->nt_len = countones(sa);
else {
if (opt_flags & OP_MASKLEN) {
errno = 0;
preflen = strtol(prefp, NULL, 10);
if (preflen == LONG_MIN && errno == ERANGE)
goto fail;