Andreas Schwab:
When the file size is very large or the filesystem is poor, the read(2)
systemcall may not read all of the file. In this case, the return value
will be shorter than the requested bytes.
Even worse, if read returns -1 then this writes beyond array bounds.
Also, file_size
[EMAIL PROTECTED] writes:
builtins/evalfile.c
_evalfile()
{
fd = open (filename, O_RDONLY);
fstat (fd, finfo);
file_size = (size_t)finfo.st_size;
string = (char *)xmalloc (1 + file_size);
result = read (fd, string, file_size);
string[result] = '\0';
;;;
}
(I checked
Matthew Woehlke [EMAIL PROTECTED] writes:
Um. In fact, it is also an *ERROR* (i.e. read() will fail outright with -
IIRC - EINVAL) to try to read more than SSIZE_MAX bytes at once. Many, but
not all, systems define SSIZE_MAX to be a very large value, but it may be
as small as 32k. I guess
Andreas Schwab wrote:
Matthew Woehlke writes:
Um. In fact, it is also an *ERROR* (i.e. read() will fail outright with -
IIRC - EINVAL) to try to read more than SSIZE_MAX bytes at once. Many, but
not all, systems define SSIZE_MAX to be a very large value, but it may be
as small as 32k. I guess
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
According to Matthew Woehlke on 3/23/2007 1:38 PM:
Huh? I never said anything about ssize_t, I said SSIZE_MAX which appears
to be guaranteed by POSIX to be at least 32 *kilobytes*,
SSIZE_MAX is guaranteed to be the maximum value that fits in
Eric Blake wrote:
According to Matthew Woehlke on 3/23/2007 1:38 PM:
Huh? I never said anything about ssize_t, I said SSIZE_MAX which appears
to be guaranteed by POSIX to be at least 32 *kilobytes*,
SSIZE_MAX is guaranteed to be the maximum value that fits in ssize_t.
Again, if your ssize_t
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
According to Matthew Woehlke on 3/23/2007 2:40 PM:
SSIZE_MAX is guaranteed to be the maximum value that fits in ssize_t.
Again, if your ssize_t is smaller than 32 bits, your platform has other
issues. Just because POSIX allows ssize_t to be as
Matthew Woehlke [EMAIL PROTECTED] writes:
Hmm... well then I guess this is broken:
/usr/include/limits.h:#define SSIZE_MAX53248/* max single I/O
size, 52K */
The creativity of system designers always amazes me. :-(
Andreas.
--
Andreas Schwab, SuSE Labs, [EMAIL PROTECTED]