From owner-freebsd-bugs@FreeBSD.ORG Wed May 6 23:30:05 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 69A241065675 for ; Wed, 6 May 2009 23:30:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 2BDF58FC23 for ; Wed, 6 May 2009 23:30:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n46NU59a057098 for ; Wed, 6 May 2009 23:30:05 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n46NU5Cd057093; Wed, 6 May 2009 23:30:05 GMT (envelope-from gnats) Resent-Date: Wed, 6 May 2009 23:30:05 GMT Resent-Message-Id: <200905062330.n46NU5Cd057093@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, Yuri Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E490D106566C for ; Wed, 6 May 2009 23:25:47 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id D30558FC23 for ; Wed, 6 May 2009 23:25:47 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n46NPljY079025 for ; Wed, 6 May 2009 23:25:47 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id n46NPlSc079024; Wed, 6 May 2009 23:25:47 GMT (envelope-from nobody) Message-Id: <200905062325.n46NPlSc079024@www.freebsd.org> Date: Wed, 6 May 2009 23:25:47 GMT From: Yuri To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/134320: strtol: overflow error when it shouldn't be X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 May 2009 23:30:05 -0000 >Number: 134320 >Category: misc >Synopsis: strtol: overflow error when it shouldn't be >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed May 06 23:30:04 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Yuri >Release: 7.2-PRERELEASE >Organization: n/a >Environment: >Description: I look at the testcase: --------------------------------- #include #include #include #include #include main() { const char *nptr = "d223d221"; long l = ::strtol(nptr, NULL, 16); printf("l=%x errno=%i err=%s\n", l, errno, strerror(errno)); } ------------------------ It prints: l=7fffffff errno=34 err=Result too large Why result is too large? 0xd223d221 is a valid representation of a signed 32-bit integer between LONG_MIN=-2,147,483,648(0x80000000) and LONG_MAX=+2,147,483,647(0x7fffffff). So strtol could convert the value but didn't. >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: