This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH/RFC] Fix interactive half of libstdc++/6745
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Paolo Carlini <pcarlini at rocketmail dot com>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: 18 Nov 2002 08:37:54 +0100
- Subject: Re: [PATCH/RFC] Fix interactive half of libstdc++/6745
- Organization: Integrable Solutions
- References: <20021117203259.83201.qmail@web13905.mail.yahoo.com>
Paolo Carlini <pcarlini@rocketmail.com> writes:
| Hi everyone, hi Benjamin,
|
| Jonathan Lennox fixed the non-interactive half of the
| PR (and the related 8071, 8127) by adding code dealing
| with in_avail == 0 like this:
|
| ...
| else {
| _CharT __buf[256];
| streamsize __charsread = __sbin->sgetn(__buf,
| sizeof(__buf));
If this bit was already there in source, then I beleive it is
incorrect as sizeof(__buf) is 256 * sizeof (_CharT) which is not
necessarily 256 and we would get a buffer overrun :-(.
It should read either
__sbin->sgetn(__buf, sizeof (__buf) / sizeof (_CharT))
or
__sbin->sgetn(__buf, __array_length(__buf))
where __array_length() is a general utility written as
template<typename _Tp, std::size_t _Np>
inline std::size_t
__array_length(const _Tp (&)[_Np])
{ return _Np; }
-- Gaby