On 13 Mar 2000, at 11:20, Eli Zaretskii wrote:

> On Mon, 13 Mar 2000, J. David Bryan wrote:
> 
> > However, 
> > the Cygnus implementation of "read" checks to ensure that the entire
> > buffer is writable before actually retrieving the file data.
> 
> I would argue that this is a bug in the Cygwin library.  Please be sure to
> report this to the Cygwin maintainers.

I will pass it on to Cygnus, but I'm interested in understanding how you 
view this as improper behavior in Cygwin's "read" routine.  Makeinfo is 
doing the equivalent of:

  char x[100];

  ... = read (..., &x, 200);

Surely this cannot be viewed as correct?  Or are you saying that returning 
"-1" is in error?

I gather Cygwin's "read" routine is attempting to ensure that it doesn't 
segfault due to an improperly sized buffer.  It appears to me to be an 
error to request more bytes than the buffer can hold, regardless of whether 
the file actually has that many bytes left in it or not, *unless* this 
behavior is explicitly allowed by some standard.  I confess that I have no 
idea if it is or isn't!  :-)


> Thanks for the fix and a clear explanation of the problem.

You're welcome.


> I'm not sure the fixed code is good enough for Unix (the file could grow as
> you read it), but it surely is good enough for DOS/Windows.

The file is opened O_RDONLY.  Does that allow for concurrent writing?  I 
don't know enough Unix to know.

However, if the file grows, then the current Makeinfo code will fault too, 
because the buffer is never increased to compensate.  It'll overwrite the 
end of the buffer.

Thanks much for your reply!

                                      -- Dave Bryan

Reply via email to