Subject: Huge bug with C read() function for DOS text files
From: [email-masked] (Daniel Sands)

1 May 1998 18:33:33 -0700
Message-ID: <[email-masked]>
Reply-To: [email-masked]
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: [email-masked]

I noticed while trying to modify BASH that there is a huge problem
introduced when reading a text file which was formatted for DOS.  The
problem is with the .DEF compiler in Bash's builtins directory.  Here's
what happens:

   1) It stats the file to get the size
   2) It opens for text mode and reads the entire file into a buffer

The read line looks like this:
  if (read (fd, buffer, finfo.st_size) < finfo.st_size/2)

The C function reads finfo.st_size bytes from the file, but then removes
#CR bytes (the number of CR's).

The bug:  Even though it removed #CR bytes, it still returns that it
read finfo.st_size bytes, and includes the #CR bytes at the end which
should have been completely thrown out.  Because of this, MKBUILTINS.C
writes extra junk to the .C file that it creates, causing a CPP error.

This is probably the reason that so many text programs do not work
anymore.
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".