]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
2000-02-02 Roland McGrath <roland@baalperazim.frob.com>
authorRoland McGrath <roland@gnu.org>
Thu, 3 Feb 2000 01:21:52 +0000 (01:21 +0000)
committerRoland McGrath <roland@gnu.org>
Thu, 3 Feb 2000 01:21:52 +0000 (01:21 +0000)
* sysdeps/mach/hurd/readlink.c (__readlink): Don't clobber original
LEN value with io_read result; save it and compare them just in case
the server bogusly returns more than we asked for.
* sysdeps/mach/hurd/recv.c (recv): Likewise for socket_recv.
* sysdeps/mach/hurd/recvfrom.c (recvfrom): Likewise.
* hurd/fd-read.c (_hurd_fd_read): Likewise for io_read.
Initialize NREAD before the RPC.  I think this must only have failed
to bomb before because all the servers always return ool data(?).

hurd/fd-read.c
sysdeps/mach/hurd/readlink.c
sysdeps/mach/hurd/recv.c
sysdeps/mach/hurd/recvfrom.c

index 8bfc03ab8b44b0fbd89d6b54c876b3a9ef9a3f65..a0191a6de09622547962fc945c15c7104d36ec22 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1993,94,95,97,2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -35,11 +35,14 @@ _hurd_fd_read (struct hurd_fd *fd, void *buf, size_t *nbytes)
     }
 
   data = buf;
+  nread = *nbytes;
   if (err = HURD_FD_PORT_USE (fd, _hurd_ctty_input (port, ctty, readfd)))
     return err;
 
   if (data != buf)
     {
+      if (nread > *nbytes)     /* Server funny business, shouldn't happen.  */
+       *nbytes = nread;
       memcpy (buf, data, nread);
       __vm_deallocate (__mach_task_self (), (vm_address_t) data, nread);
     }
index b79269256fb6adea74ec7b37ba7c01e28a42e450..86f50f507786838317b838fd696a00d95e0814dc 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 94, 95, 97 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,93,94,95,97,2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -44,12 +44,15 @@ __readlink (file_name, buf, len)
     if (S_ISLNK (st.st_mode))
       {
        char *rbuf = buf;
+       size_t got;
 
-       err = __io_read (file, &rbuf, &len, 0, len);
+       err = __io_read (file, &rbuf, &got, 0, len);
+       if (got < len)
+         len = got;
        if (!err && rbuf != buf)
          {
            memcpy (buf, rbuf, len);
-           __vm_deallocate (__mach_task_self (), (vm_address_t)rbuf, len);
+           __vm_deallocate (__mach_task_self (), (vm_address_t)rbuf, got);
          }
       }
     else
index 6ae3a6ad8b429e5dad0f563cdde2c6991815f05c..df76e77b5b4494dddaa9ab72c3b081c1c27fea9d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1994,97,2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -56,6 +56,8 @@ recv (fd, buf, n, flags)
 
   if (bufp != buf)
     {
+      if (nread > n)           /* Server funny business, shouldn't happen.  */
+       nread = n;
       memcpy (buf, bufp, nread);
       __vm_deallocate (__mach_task_self (), (vm_address_t) bufp, nread);
     }
index b39528628c424f98bfae6bb31df95d228f465f91..d4b4deccffe06401e3ec961577c329e8dd598923 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994, 1997, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1994,97,99,2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -76,7 +76,7 @@ recvfrom (fd, buf, n, flags, addrarg, addr_len)
          __mach_port_deallocate (__mach_task_self (), addrport);
          return __hurd_dfail (fd, err);
        }
-      
+
       if (*addr_len > buflen)
        *addr_len = buflen;
 
@@ -97,6 +97,8 @@ recvfrom (fd, buf, n, flags, addrarg, addr_len)
 
   if (bufp != buf)
     {
+      if (nread > n)           /* Server funny business, shouldn't happen.  */
+       nread = n;
       memcpy (buf, bufp, nread);
       __vm_deallocate (__mach_task_self (), (vm_address_t) bufp, nread);
     }