Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/share/misc check strtol for ERANGE overflow too...
details: https://anonhg.NetBSD.org/src/rev/1de0524dbab4
branches: trunk
changeset: 545858:1de0524dbab4
user: lukem <lukem%NetBSD.org@localhost>
date: Thu Apr 17 02:59:29 2003 +0000
description:
check strtol for ERANGE overflow too...
diffstat:
share/misc/style | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diffs (38 lines):
diff -r 6794af373fe2 -r 1de0524dbab4 share/misc/style
--- a/share/misc/style Thu Apr 17 02:54:07 2003 +0000
+++ b/share/misc/style Thu Apr 17 02:59:29 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: style,v 1.24 2003/03/10 03:50:38 lukem Exp $ */
+/* $NetBSD: style,v 1.25 2003/04/17 02:59:29 lukem Exp $ */
/*
* The revision control tag appears first, with a blank line after it.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2000\n\
The NetBSD Foundation, inc. All rights reserved.\n");
-__RCSID("$NetBSD: style,v 1.24 2003/03/10 03:50:38 lukem Exp $");
+__RCSID("$NetBSD: style,v 1.25 2003/04/17 02:59:29 lukem Exp $");
/*
* VERY important single-line comments look like this.
@@ -83,6 +83,7 @@
* The /usr include files should be sorted!
*/
#include <assert.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -205,8 +206,10 @@
bflag = 1;
break;
case 'n':
+ errno = 0;
num = strtol(optarg, &ep, 10);
- if (num <= 0 || *ep != '\0')
+ if (num <= 0 || *ep != '\0' || (errno == ERANGE &&
+ (num == LONG_MAX || num == LONG_MIN)) )
errx(1, "illegal number -- %s", optarg);
break;
case '?':
Home |
Main Index |
Thread Index |
Old Index