From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10926 invoked by alias); 6 Dec 2006 01:54:26 -0000 Received: (qmail 8848 invoked by uid 48); 6 Dec 2006 01:54:16 -0000 Date: Wed, 06 Dec 2006 01:54:00 -0000 From: "jsm28 at gcc dot gnu dot org" To: glibc-bugs@sources.redhat.com Message-ID: <20061206015415.3664.jsm28@gcc.gnu.org> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug libc/3664] New: strtod handling of all-zeros numbers broken X-Bugzilla-Reason: CC Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2006-12/txt/msg00010.txt.bz2 strtod_l.c contains a conditional which is never going to pass because it requires both base == 16 and base != 16. if ((c < L_('0') || c > L_('9')) && (base == 16 && (c < (CHAR_TYPE) TOLOWER (L_('a')) || c > (CHAR_TYPE) TOLOWER (L_('f')))) #ifdef USE_WIDE_CHAR && c != (wint_t) decimal #else && ({ for (cnt = 0; decimal[cnt] != '\0'; ++cnt) if (decimal[cnt] != cp[cnt]) break; decimal[cnt] != '\0'; }) #endif && (base == 16 && (cp == start_of_digits || (CHAR_TYPE) TOLOWER (c) != L_('p'))) && (base != 16 && (CHAR_TYPE) TOLOWER (c) != L_('e'))) I believe the fix is to change "base == 16 &&" to "base != 16 ||" in both places, "base != 16 &&" to "base == 16 ||", "c < (CHAR_TYPE) TOLOWER (L_('a'))" to "(CHAR_TYPE) TOLOWER (c) < L_('a')" and likewise for 'f'. The following test shows that this causes an actual bug. #include int main(void) { const char *s = "0x"; char *ep; double r = strtod(s, &ep); if (r != 0) abort(); if (ep != s + 1) abort(); exit(0); } -- Summary: strtod handling of all-zeros numbers broken Product: glibc Version: 2.4 Status: NEW Severity: normal Priority: P2 Component: libc AssignedTo: drepper at redhat dot com ReportedBy: jsm28 at gcc dot gnu dot org CC: glibc-bugs at sources dot redhat dot com http://sourceware.org/bugzilla/show_bug.cgi?id=3664 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.