bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

minor bug in bash 2.03 (zwrite)


From: Art Medlar
Subject: minor bug in bash 2.03 (zwrite)
Date: Mon, 30 Oct 2000 12:54:43 -0800 (PST)

In the function zwrite, in the file builtins/evalstring.c, in the
case of a partial write the pointer `buf' is not updated and the
next write will re-write the initial contents of buf.

I believe a fix is to insert the line marked with /* XXX */ below.

--art


static int
zwrite (fd, buf, nb)
     int fd;
     unsigned char *buf;
     int nb;
{
  int n, i, nt;

  for (n = nb, nt = 0;;)
    {
      i = write (fd, buf, n);
      if (i > 0)
        {
          n -= i;
          if (n <= 0)
            return nb;
          buf += i;   /* XXX */
        }
      else if (i == 0)
        {
          if (++nt > 3)
            return (nb - n);
        }
      else if (errno != EINTR)
        return -1;
    }
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]