Re: [PATCH] svfwscanf: Simplify _sungetwc_r to eliminate apparent buffer overflow

Keith Packard <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
Corinna Vinschen <[email protected]> writes:

> LGTM.  Under the unlikely assumption that wscanf gets extended in future
> and has to ungetc a char different from the input char, how do we catch
> that?  Do we need a hint, somehow, somewhere?

I can't imagine a case where that wouldn't be a bug; the only reason I
know that ungetc takes the old char is because stdio might not still
have it in the buffer, and that can't happen for string sources.

However, I also don't know how we'd catch this bug at compile time, and
having the string source work differently in this case than the file
source means testing using string sources might not uncover a bug that
would appear with file sources.

A reasonable alternative would be to have the wchar_t version call the
char version multiple times, instead of just doing it inline; that would
avoid any semantic difference, which seems like a feature. I'll post a
patch that does it this way shortly and see which you prefer.

-- 
-keith
signature.asc (application/pgp-signature, 832 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEw4O3eCVWE9/bQJ2R2yIaaQAAABEFAmEdNZkACgkQ2yIaaQAA
ABHLhA/+KO6wggwtnjHaCFdn/50fklSwxv8YQgpuLqiMRdbIluXq5a6kDRgFYPBM
RrAKeZHpe82JPl9vqzFSZfNmN0bZKO4dpSckYz1KXvZDDEP6sSZspEGFNTY+v8FT
90cOz65KPiD68kP26yfyc4qZeAYhmVJ8YOxWF9QAgVn8usw874q5VPsgfrny4TTt
P0qf7sRl3wNjdXvdiAr+X5Mo5UlU4tvzwVXGUTJfhaep+LaT6JN8ar/FgxnRY3qg
RN2e+9vsq3A2hmgDWDUIQUQebeot6nchPneaQcs2ORJs9w0eBL6khAERuCxXFv5a
3cFiDsYT0X66IG2VbBwQNHwaawuBfHNqGDpBAiZJCcWe41y3RwLCYkjVW/ktMbC7
CsXLPKlQBpbQv8RzfgR2YTih1NifsRqWi2ADJPgEeOJFPYDJV3l3kZb8o1xf+poa
2GdXiqfkv3hqxhZvpSI3wPGcXj/0Q1ZWDpgeStOcuaqWNaFePn8FqJvQyDBSrFNV
dPPdgGUndgRtSWGSY6E+eMQsxJPhLH8+3Pt3bR/3WeN5Fh1uiIVjFNcpbaNOzQWy
2X59i/EEihrDOZBM46GaoyEcDFfsujVqYrXPL3R2mk70oOEKH1GE4MyoUFuckul1
inEvhoPxXAZAUqOM32UXKfUtXYZowmPh3wLhriXb4FNEncGq8RY=
=TOho
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.