[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
source(builtin) and read(2)
From: |
hooanon05 |
Subject: |
source(builtin) and read(2) |
Date: |
Thu, 22 Mar 2007 15:32:19 +0900 |
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../bash/include
-I../bash/lib -g -O2
uname output: Linux jroun 2.6.8-16sarge5jroun #1 Tue Nov 21 16:22:30 JST 2006
i686 GNU/Linux
Machine Type: i386-pc-linux-gnu
Bash Version: 2.05b
Patch Level: 0
Release Status: release
Description:
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)finfo.st_size;
string = (char *)xmalloc (1 + file_size);
result = read (fd, string, file_size);
string[result] = '\0';
;;;
}
(I checked bash-3.0 too)
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.
Should bash read the remaining bytes, or is it a problem of filesystem?
I think that read(2) systemcall doesn't guarantee the requested bytes
are all retrived.
Does it guaranteed that the regular file is read all?
Thank you very much for your good work.
Repeat-By:
[Describe the sequence of events that causes the problem
to occur.]
Fix:
[Description of how to fix the problem. If you don't know a
fix for the problem, don't include this section.]
- source(builtin) and read(2),
hooanon05 <=
- Re: source(builtin) and read(2), Andreas Schwab, 2007/03/23
- Re: source(builtin) and read(2), Matthew Woehlke, 2007/03/23
- Re: source(builtin) and read(2), Andreas Schwab, 2007/03/23
- Re: source(builtin) and read(2), Matthew Woehlke, 2007/03/23
- Re: source(builtin) and read(2), Eric Blake, 2007/03/23
- Re: source(builtin) and read(2), Matthew Woehlke, 2007/03/23
- Re: source(builtin) and read(2), Eric Blake, 2007/03/23
- Re: source(builtin) and read(2), Matthew Woehlke, 2007/03/23
- Re: source(builtin) and read(2), Andreas Schwab, 2007/03/23