From owner-freebsd-current Wed Jan 27 20:24:47 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id UAA06514 for freebsd-current-outgoing; Wed, 27 Jan 1999 20:24:47 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.26.10.9]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id UAA06509 for ; Wed, 27 Jan 1999 20:24:43 -0800 (PST) (envelope-from bde@godzilla.zeta.org.au) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.7/8.8.7) id PAA01617; Thu, 28 Jan 1999 15:24:35 +1100 Date: Thu, 28 Jan 1999 15:24:35 +1100 From: Bruce Evans Message-Id: <199901280424.PAA01617@godzilla.zeta.org.au> To: archie@whistle.com, dillon@apollo.backplane.com Subject: Re: kern/subr_scanf array index of signed char Cc: current@FreeBSD.ORG Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >:Matthew Dillon writes: >:> goto match_failure; >:> } else { >:> p0 = p = va_arg(ap, char *); >:> - while (ccltab[*inp]) { >:> + while (ccltab[(int)(unsigned char)*inp]) { >:> inr--; >:> *p++ = *inp++; >:> if (--width == 0) >: >:Just curious.. why do you need the "(int)" cast? >: >:-Archie > > Actually, it could very well be that I don't. I didn't want to spend > the time to check to see if the compiler warned on unsigned-char array > indexes. You can change it back if unsigned char array indexes do not > produce a warning. Sloppy thinking. How would you know if you fixed the bug unless you checked that you fixed the bug instead of breaking the warning? The bug was that on systems with signed chars, *inp gave negative array indexes if the caller passes a format string with negative characters in certain positions. There are still lots of related isfoo(*inp) bugs. All these bugs are more serious in the userland. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message