Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/sysctl When converting a string to a number, also make ...
details: https://anonhg.NetBSD.org/src/rev/c487384ee710
branches: trunk
changeset: 565996:c487384ee710
user: atatat <atatat%NetBSD.org@localhost>
date: Sun Apr 25 05:36:49 2004 +0000
description:
When converting a string to a number, also make sure that you didn't
convert an empty string to a zero.
Follow on to PR bin/25115 in private email.
diffstat:
sbin/sysctl/sysctl.c | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diffs (81 lines):
diff -r 7f0764a28a3d -r c487384ee710 sbin/sysctl/sysctl.c
--- a/sbin/sysctl/sysctl.c Sun Apr 25 04:35:36 2004 +0000
+++ b/sbin/sysctl/sysctl.c Sun Apr 25 05:36:49 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysctl.c,v 1.93 2004/04/23 12:03:39 atatat Exp $ */
+/* $NetBSD: sysctl.c,v 1.94 2004/04/25 05:36:49 atatat Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
#if 0
static char sccsid[] = "@(#)sysctl.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: sysctl.c,v 1.93 2004/04/23 12:03:39 atatat Exp $");
+__RCSID("$NetBSD: sysctl.c,v 1.94 2004/04/25 05:36:49 atatat Exp $");
#endif
#endif /* not lint */
@@ -947,7 +947,7 @@
}
errno = 0;
addr = (void*)strtoul(value, &t, 0);
- if (*t != '\0' || errno != 0) {
+ if (t == value || *t != '\0' || errno != 0) {
sysctlperror(
"%s: '%s' is not a valid address\n",
nname, value);
@@ -996,7 +996,7 @@
* right?
*/
sz = strtoul(value, &t, 0);
- if (*t != '\0' || errno != 0) {
+ if (t == value || *t != '\0' || errno != 0) {
sysctlperror(
"%s: '%s' is not a valid size\n",
nname, value);
@@ -1006,7 +1006,7 @@
else if (strcmp(key, "n") == 0) {
errno = 0;
q = strtoq(value, &t, 0);
- if (*t != '\0' || errno != 0 ||
+ if (t == value || *t != '\0' || errno != 0 ||
q < INT_MIN || q > UINT_MAX) {
sysctlperror(
"%s: '%s' is not a valid mib number\n",
@@ -1089,7 +1089,7 @@
case CTLTYPE_INT:
errno = 0;
q = strtoq(data, &t, 0);
- if (*t != '\0' || errno != 0 ||
+ if (t == data || *t != '\0' || errno != 0 ||
q < INT_MIN || q > UINT_MAX) {
sysctlperror(
"%s: '%s' is not a valid integer\n",
@@ -1121,7 +1121,7 @@
case CTLTYPE_QUAD:
errno = 0;
uq = strtouq(data, &t, 0);
- if (*t != '\0' || errno != 0) {
+ if (t == data || *t != '\0' || errno != 0) {
sysctlperror(
"%s: '%s' is not a valid quad\n",
nname, value);
@@ -1586,7 +1586,7 @@
sysctlperror("%s: value too large\n", value);
EXIT(1);
}
- if (*t != '\0') {
+ if (t == value || *t != '\0') {
sysctlperror("%s: not a number\n", value);
EXIT(1);
}
@@ -2168,7 +2168,7 @@
else {
errno = 0;
nlim = strtouq(value, &t, 0);
- if (*t != '\0' || errno != 0) {
+ if (t == value || *t != '\0' || errno != 0) {
sysctlperror("%s: '%s' is not a valid limit\n",
sname, value);
EXIT(1);
Home |
Main Index |
Thread Index |
Old Index