This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

preprocessor/2277: reader complains about input file larger than 8230 bytes



>Number:         2277
>Category:       preprocessor
>Synopsis:       reader complains about input file larger than 8230 bytes
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Mar 13 09:26:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Peter Zienicke
>Release:        GNU CPP version 2.95.2 19991024 (release) (sparc)
>Organization:
>Environment:
Solaris 7, UltraSparc 60.
>Description:
Using cpp with input from a pipe.
The input is larger than 10 kByte.
This results in the error message:
":0: file is too large (>8230 bytes)".

Reason is an apparent bug in source file cppfiles.c.
This allocates a buffer of length 8192 (+2+2).
Also, it calls read_and_prescan() with len==4096.
Then calls read() with length 8192 (pfile input buffer).
Read() returns with 38 read bytes which increases "offset"
to 38. Next loop calls read() again with length 8192.
This time read() returns 8192 read bytes which increases
"offset" to 8230. Now offset (==8230) is greater than
"len" (==4096), so "len" is doubled (to 8192). Still,
"offset" is larger than "len" which leads to the error
message complaining about a file that is larger than 8230
bytes.

Obviously, it is just not enough to double "len" if
"offset" has become too large. Instead, the increase of
"len" needs to take the file's buffer size (or at least the
number of successfully read bytes) into account.
>How-To-Repeat:

>Fix:
(workaround: I can use a temporary file instead of the
pipe as input).

Suggestion for final fix in cppfiles.c:
in read_and_prescan() replace the assignment "len *= 2;"
with something like "len += max(len,count);"
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]