From f51bc9e68bf01ca9861543da613be76b27ba19ef Mon Sep 17 00:00:00 2001 From: joda Date: Mon, 17 Sep 2001 10:05:57 +0000 Subject: [PATCH] use strtol instead of atoi to catch non numeric values --- usr.sbin/pcictl/pcictl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/usr.sbin/pcictl/pcictl.c b/usr.sbin/pcictl/pcictl.c index 9d57212b289f..e418dc82958a 100644 --- a/usr.sbin/pcictl/pcictl.c +++ b/usr.sbin/pcictl/pcictl.c @@ -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 @@ cmd_dump(int argc, char *argv[]) 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