This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 1/2] iconv_prog: Don't slurp whole input at once [BZ #6050]
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Rich Felker <dalias at libc dot org>
- Cc: Benjamin Herr <ben at 0x539 dot de>, <libc-alpha at sourceware dot org>
- Date: Mon, 10 Aug 2015 14:29:45 +0000
- Subject: Re: [PATCH 1/2] iconv_prog: Don't slurp whole input at once [BZ #6050]
- Authentication-results: sourceware.org; auth=none
- References: <1439158464-18443-1-git-send-email-ben at 0x539 dot de> <1439158464-18443-2-git-send-email-ben at 0x539 dot de> <20150809224618 dot GK14639 at brightrain dot aerifal dot cx>
On Sun, 9 Aug 2015, Rich Felker wrote:
> On Mon, Aug 10, 2015 at 12:14:23AM +0200, Benjamin Herr wrote:
> > To still support reporting the position of invalid sequences in the
> > input, we count consumed input bytes explicitly. As overflow of that
> > counter is now possible, we use saturating addition and just mention in
> > the error message when (size_t) -1 has been reached.
>
> Why not use uint64_t? Then it's reasonable to assume overflow does not
> happen -- it would take something like a century to hit -- and you
> don't underreport in the case of huge files that fit in off_t but not
> size_t.
off64_t seems logically right for file offsets (with casts to intmax_t for
printing). But right now there are several places in iconv_prog.c that
use non-large-file interfaces for I/O (including trying to mmap the whole
file into memory without regard to st.st_size - from fstat64 - possibly
overflowing size_t). I think large file issues can reasonably be
considered a separate bug (filed in Bugzilla and fixed separately).
--
Joseph S. Myers
joseph@codesourcery.com