Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/pcictl use strtol instead of atoi to catch non nume...



details:   https://anonhg.NetBSD.org/src/rev/7c9d18f6c5df
branches:  trunk
changeset: 515131:7c9d18f6c5df
user:      joda <joda%NetBSD.org@localhost>
date:      Mon Sep 17 10:05:57 2001 +0000

description:
use strtol instead of atoi to catch non numeric values

diffstat:

 usr.sbin/pcictl/pcictl.c |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (29 lines):

diff -r c2558a6a99b4 -r 7c9d18f6c5df usr.sbin/pcictl/pcictl.c
--- a/usr.sbin/pcictl/pcictl.c  Mon Sep 17 09:33:41 2001 +0000
+++ b/usr.sbin/pcictl/pcictl.c  Mon Sep 17 10:05:57 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pcictl.c,v 1.3 2001/09/15 18:35:00 thorpej Exp $       */
+/*     $NetBSD: pcictl.c,v 1.4 2001/09/17 10:05:57 joda Exp $  */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -231,12 +231,18 @@
 int
 parse_bdf(const char *str)
 {
+       long value;
+       char *end;
 
        if (strcmp(str, "all") == 0 ||
            strcmp(str, "any") == 0)
                return (-1);
 
-       return (atoi(str));
+       value = strtol(str, &end, 0);
+       if(*end != '\0') 
+               errx(1, "\"%s\" is not a number", str);
+
+       return value;
 }
 
 void



Home | Main Index | Thread Index | Old Index