Re: source(builtin) and read(2)

2007-03-26 Thread hooanon05
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, fi

Re: source(builtin) and read(2)

2007-03-23 Thread Andreas Schwab
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 PROTECT

Re: source(builtin) and read(2)

2007-03-23 Thread Matthew Woehlke
Eric Blake wrote: 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. ...that "fits", or that "may be stored in"? Again, if your ssize_t is smaller than 32 bits, your platform has other issues. Just because POSIX allows ss

Re: source(builtin) and read(2)

2007-03-23 Thread Eric Blake
-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 b

Re: source(builtin) and read(2)

2007-03-23 Thread Matthew Woehlke
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 is

Re: source(builtin) and read(2)

2007-03-23 Thread Eric Blake
-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 ssize

Re: source(builtin) and read(2)

2007-03-23 Thread Matthew Woehlke
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 I'

Re: source(builtin) and read(2)

2007-03-23 Thread Andreas Schwab
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 gues

Re: source(builtin) and read(2)

2007-03-23 Thread Matthew Woehlke
[EMAIL PROTECTED] wrote: The source builtin command reads the given file after getting its size by fstat(2). But bash doen't check the read bytes which is a return value of read(2). builtins/evalfile.c _evalfile() { fd = open (filename, O_RDONLY); fstat (fd, &finfo); file_size = (size_t)fi

Re: source(builtin) and read(2)

2007-03-23 Thread Andreas Schwab
[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'; > ;;; > } >

source(builtin) and read(2)

2007-03-23 Thread hooanon05
Configuration Information [Automatically generated, do not change]: Machine: i386 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-pc-linux-gnu' -DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../