delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/12/11/09:29:40

From: sandmann AT clio DOT rice DOT edu (Charles Sandmann)
Message-Id: <10212111431.AA22490@clio.rice.edu>
Subject: Re: scanf buffer overflow; support 'hh' conversion specifier [PATCH]
To: djgpp-workers AT delorie DOT com
Date: Wed, 11 Dec 2002 08:31:42 -0600 (CST)
In-Reply-To: <3DF70F40.4FE00660@phekda.freeserve.co.uk> from "Richard Dawe" at Dec 11, 2002 10:11:12 AM
X-Mailer: ELM [version 2.5 PL2]
Mime-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> > > The code that causes the buffer overflow is the special handling
> > > for capitalised letters (for compatibility with Borland C) - D, I, U
> > > and O. For some reason X was included in this too. I think the code
> > > mistakenly sets 'size' to LONG for X. I think it should leave it alone
> > > and let 'size' be set by the normal mechanisms - 'h', 'l', 'll', etc.
> > 
> > I recall vaguely that some Borland compatibility is involved here.
> > Can someone please check with Borland C and Turbo C?

E - same as e with E for exponent
G - same as g with G for exponent
X - same as x with capital ABCDEF in output

D,I,U,O are not mentioned (C++ 3.0 docs, what I have handy) - so I
don't think these are Borland.  Maybe something else.

> In section 7.19.6.2, point 14 of the C99 standard (numbered page 286, but
> actually page 300 of the PDF):
> 
> "The conversion specifiers A, E, F, G, and X are also valid and behave the
> same as,
> respectively, a, e, f, g, and x."
> 
> So we can't treat X as some Borland special-case, if we want to comply with
> the C standard.

Well, if you expect output in capitals, that's a minor thing for the coder
to fix...

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019