Package: textutils
Version: 2.0-9

Hello,
there is a little nasty bug in the "head" util.
It always tries to read complete blocks in function head_bytes.
This is no problem (except performance loss) for regular files, but leads to 
problems in special files.
Here is a patch which should fix this problem:
--- head.c.orig  Sat Sep 22 22:36:45 2001
+++ head.c      Sat Sep 22 22:36:45 2001
@@ -125,7 +125,10 @@
 
   while (bytes_to_write)
     {
-      bytes_read = safe_read (fd, buffer, BUFSIZE);
+      if (bytes_to_write < BUFSIZE)
+        bytes_read = safe_read (fd, buffer, bytes_to_write);
+      else
+        bytes_read = safe_read (fd, buffer, BUFSIZE);
       if (bytes_read < 0)
        {
          error (0, errno, "%s", filename);
@@ -133,8 +136,6 @@
        }
       if (bytes_read == 0)
        break;
-      if (bytes_read > bytes_to_write)
-       bytes_read = bytes_to_write;
       if (fwrite (buffer, 1, bytes_read, stdout) == 0)
        error (EXIT_FAILURE, errno, _("write error"));
       bytes_to_write -= bytes_read;


_______________________________________________
Bug-textutils mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-textutils

Reply via email to