From owner-freebsd-bugs@FreeBSD.ORG Mon Oct 25 11:10:15 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2D11B16A4CE for ; Mon, 25 Oct 2004 11:10:15 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 118ED43D3F for ; Mon, 25 Oct 2004 11:10:15 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i9PBAECB084765 for ; Mon, 25 Oct 2004 11:10:14 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i9PBAErG084760; Mon, 25 Oct 2004 11:10:14 GMT (envelope-from gnats) Resent-Date: Mon, 25 Oct 2004 11:10:14 GMT Resent-Message-Id: <200410251110.i9PBAErG084760@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Giorgos Keramidas Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 374AC16A4CE for ; Mon, 25 Oct 2004 11:08:12 +0000 (GMT) Received: from kane.otenet.gr (kane.otenet.gr [195.170.0.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id 74C8843D45 for ; Mon, 25 Oct 2004 11:08:11 +0000 (GMT) (envelope-from keramida@bytemobile.com) Received: from orion.daedalusnetworks.priv (aris.bedc.ondsl.gr [62.103.39.226])i9PB7wN7020762 for ; Mon, 25 Oct 2004 14:08:05 +0300 Received: from orion.daedalusnetworks.priv (orion [127.0.0.1]) i9PB7ubn002482 for ; Mon, 25 Oct 2004 14:07:56 +0300 (EEST) (envelope-from keramida@orion.daedalusnetworks.priv) Received: (from keramida@localhost)i9PB7tZ2002481; Mon, 25 Oct 2004 14:07:55 +0300 (EEST) (envelope-from keramida) Message-Id: <200410251107.i9PB7tZ2002481@orion.daedalusnetworks.priv> Date: Mon, 25 Oct 2004 14:07:55 +0300 (EEST) From: Giorgos Keramidas To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/73110: ffsinfo conversion from atol() to strtol() X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Giorgos Keramidas List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Oct 2004 11:10:15 -0000 >Number: 73110 >Category: bin >Synopsis: ffsinfo conversion from atol() to strtol() >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Oct 25 11:10:14 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Giorgos Keramidas >Release: FreeBSD 6.0-CURRENT i386 >Organization: >Environment: System: FreeBSD orion.daedalusnetworks.priv 6.0-CURRENT FreeBSD 6.0-CURRENT #4: \ Fri Oct 22 17:12:12 EEST 2004 root@orion.daedalusnetworks.priv:/usr/obj/usr/src/sys/ORION i386 >Description: The ffsinfo utility uses atol() to parse numeric values out of optarg strings. This isn't necessarily a bug, but it can be slightly inconvenient, because atol() doesn't know how to parse hexadecimal or octal numbers and at least one of the options of ffsinfo(8) would be easier to use if it did. Changing atol() -> strtol() allows one to use hex masks for -l MASK, i.e.: orion:/a/freebsd/src/sbin/ffsinfo# ./ffsinfo -l 0x3ff / A word of caution: the source of ffsinfo.c does not follow style(9). This is why I used a style similar to the one of the original source in my diff. >How-To-Repeat: >Fix: --- ffsinfo.patch begins here --- Index: ffsinfo.c =================================================================== RCS file: /home/ncvs/src/sbin/ffsinfo/ffsinfo.c,v retrieving revision 1.7 diff -u -u -r1.7 ffsinfo.c --- ffsinfo.c 26 Jul 2004 15:04:57 -0000 1.7 +++ ffsinfo.c 25 Oct 2004 11:02:19 -0000 @@ -63,6 +63,7 @@ #include #include +#include #include #include #include @@ -148,19 +149,25 @@ while ((ch=getopt(argc, argv, "g:i:l:o:")) != -1) { switch(ch) { case 'g': - cfg_cg=atol(optarg); + cfg_cg=strtol(optarg, NULL, 0); + if(errno == EINVAL||errno == ERANGE) + err(1, "%s", optarg); if(cfg_cg < -1) { usage(); } break; case 'i': - cfg_in=atol(optarg); + cfg_in=strtol(optarg, NULL, 0); + if(errno == EINVAL||errno == ERANGE) + err(1, "%s", optarg); if(cfg_in < 0) { usage(); } break; case 'l': - cfg_lv=atol(optarg); + cfg_lv=strtol(optarg, NULL, 0); + if(errno == EINVAL||errno == ERANGE) + err(1, "%s", optarg); if(cfg_lv < 0x1||cfg_lv > 0x3ff) { usage(); } --- ffsinfo.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: