]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
rx: Zero unitialized uio structs
authorAndrew Deason <adeason@sinenomine.net>
Wed, 4 Feb 2015 16:25:38 +0000 (10:25 -0600)
committerDaria Brashear <shadow@your-file-system.com>
Wed, 4 Feb 2015 22:21:41 +0000 (17:21 -0500)
We use some uio structures that were allocated on the stack, but we
only initialize them by initializing individual fields. On some
platforms (Solaris is one known example, but probably not the only
one), there are additional fields we do not initialize. Since we
cannot be certain of what any additional fields there may be, just
zero the whole thing.

This is basically the same change as
I0eae0b49a70aee19f3a9ec118b03cfb3a6bd03a3, but in the rx subtree.

Change-Id: I400144143bb1f47409eccb931daacc8a5058e074
Reviewed-on: http://gerrit.openafs.org/11711
Tested-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Perry Ruiter <pruiter@sinenomine.net>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Daria Brashear <shadow@your-file-system.com>
src/rx/DARWIN/rx_knet.c
src/rx/FBSD/rx_knet.c
src/rx/HPUX/rx_knet.c
src/rx/IRIX/rx_knet.c
src/rx/NBSD/rx_knet.c
src/rx/OBSD/rx_knet.c
src/rx/SOLARIS/rx_knet.c

index d0d0f797cbbf894947f2ae499172eefa46c688b2..8cc24c8e987406b6546b3b72201e50c61c83b1b4 100644 (file)
@@ -166,6 +166,14 @@ int
 osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
               int nvecs, int *alength)
 {
+    int i;
+    struct iovec iov[RX_MAXIOVECS];
+    struct sockaddr *sa = NULL;
+    int code;
+    size_t resid;
+
+    int haveGlock = ISAFS_GLOCK();
+
 #ifdef AFS_DARWIN80_ENV
     socket_t asocket = (socket_t)so;
     struct msghdr msg;
@@ -175,14 +183,9 @@ osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
 #else
     struct socket *asocket = (struct socket *)so;
     struct uio u;
+    memset(&u, 0, sizeof(u));
 #endif
-    int i;
-    struct iovec iov[RX_MAXIOVECS];
-    struct sockaddr *sa = NULL;
-    int code;
-    size_t resid;
-
-    int haveGlock = ISAFS_GLOCK();
+    memset(&iov, 0, sizeof(iov));
     /*AFS_STATCNT(osi_NetReceive); */
 
     if (nvecs > RX_MAXIOVECS)
@@ -282,6 +285,10 @@ int
 osi_NetSend(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
            int nvecs, afs_int32 alength, int istack)
 {
+    afs_int32 code;
+    int i;
+    struct iovec iov[RX_MAXIOVECS];
+    int haveGlock = ISAFS_GLOCK();
 #ifdef AFS_DARWIN80_ENV
     socket_t asocket = (socket_t)so;
     struct msghdr msg;
@@ -289,11 +296,9 @@ osi_NetSend(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
 #else
     struct socket *asocket = (struct socket *)so;
     struct uio u;
+    memset(&u, 0, sizeof(u));
 #endif
-    afs_int32 code;
-    int i;
-    struct iovec iov[RX_MAXIOVECS];
-    int haveGlock = ISAFS_GLOCK();
+    memset(&iov, 0, sizeof(iov));
 
     AFS_STATCNT(osi_NetSend);
     if (nvecs > RX_MAXIOVECS)
index fef1d4f658e28105934c859df4f83a64e8ec5efb..1e8a013c984753a7c898538df3167f7cb3a2c737 100644 (file)
@@ -26,6 +26,10 @@ osi_NetReceive(osi_socket asocket, struct sockaddr_in *addr,
     int code;
 
     int haveGlock = ISAFS_GLOCK();
+
+    memset(&u, 0, sizeof(u));
+    memset(&iov, 0, sizeof(iov));
+
     /*AFS_STATCNT(osi_NetReceive); */
 
     if (nvecs > RX_MAXIOVECS)
@@ -137,6 +141,9 @@ osi_NetSend(osi_socket asocket, struct sockaddr_in *addr, struct iovec *dvec,
     struct uio u;
     int haveGlock = ISAFS_GLOCK();
 
+    memset(&u, 0, sizeof(u));
+    memset(&iov, 0, sizeof(iov));
+
     AFS_STATCNT(osi_NetSend);
     if (nvecs > RX_MAXIOVECS)
        osi_Panic("osi_NetSend: %d: Too many iovecs.\n", nvecs);
index c797cfd239044276293c32939496dee0e1a554c1..8ea0263cb401d72c8049ad7168ccc4ee32c5b5c5 100644 (file)
@@ -225,6 +225,9 @@ osi_NetSend(struct socket *asocket, struct sockaddr_in *addr,
     int code;
     int size = sizeof(struct sockaddr_in);
 
+    memset(&uio, 0, sizeof(uio));
+    memset(&temp, 0, sizeof(temp));
+
     /* Guess based on rxk_NewSocket */
     bp = allocb((size + SO_MSGOFFSET + 1), BPRI_MED);
     if (!bp)
@@ -258,6 +261,9 @@ osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
     int flags = 0;
     MBLKP bp, sp;
 
+    memset(&tuio, 0, sizeof(tuio));
+    memset(&tmpvec, 0, sizeof(tempvec));
+
     if (nvecs > RX_MAXWVECS + 2) {
        osi_Panic("Too many (%d) iovecs passed to osi_NetReceive\n", nvecs);
     }
index 1bab1a66e1730a1cbf103a272902518cdc31f621..42d9b4da55b0e12ab8a7714790d70362dd7d1941 100644 (file)
@@ -58,6 +58,9 @@ osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
     BHV_PDATA(&bhv) = (void *)so;
 #endif
 
+    memset(&tuio, 0, sizeof(tuio));
+    memset(&tmpvec, 0, sizeof(tmpvec));
+
     tuio.uio_iov = tmpvec;
     tuio.uio_iovcnt = nvecs;
     tuio.uio_offset = 0;
@@ -430,6 +433,9 @@ osi_NetSend(asocket, addr, dvec, nvec, asize, istack)
     int i;
     bhv_desc_t bhv;
 
+    memset(&tuio, 0, sizeof(tuio));
+    memset(&tvecs, 0, sizeof(tvecs));
+
     if (nvec > RX_MAXWVECS + 1) {
        osi_Panic("osi_NetSend: %d: Too many iovecs.\n", nvec);
     }
index e08b27864ee5fd605f07fa90ba9866f88e77c7ba..6ee14101bb0b1bba5d060f2a07c9c266e0745b68 100644 (file)
@@ -24,6 +24,9 @@ osi_NetReceive(osi_socket asocket, struct sockaddr_in *addr,
 
     int glocked = ISAFS_GLOCK();
 
+    memset(&u, 0, sizeof(u));
+    memset(&iov, 0, sizeof(iov));
+
     if (nvecs > RX_MAXIOVECS)
        osi_Panic("osi_NetReceive: %d: too many iovecs\n", nvecs);
 
@@ -94,6 +97,9 @@ osi_NetSend(osi_socket asocket, struct sockaddr_in *addr, struct iovec *dvec,
     struct mbuf *nam;
     int glocked = ISAFS_GLOCK();
 
+    memset(&u, 0, sizeof(u));
+    memset(&iov, 0, sizeof(iov));
+
     AFS_STATCNT(osi_NetSend);
     if (nvecs > RX_MAXIOVECS)
        osi_Panic("osi_NetSend: %d: Too many iovecs.\n", nvecs);
index 569caac4619d35649e7aed2dfed8cb0c3a4bf1cf..9e61c33d654afae052aa47dbdbeb1fcc9d374ac7 100644 (file)
@@ -24,6 +24,9 @@ osi_NetReceive(osi_socket asocket, struct sockaddr_in *addr,
 
     int haveGlock = ISAFS_GLOCK();
 
+    memset(&u, 0, sizeof(u));
+    memset(&iov, 0, sizeof(iov));
+
     if (nvecs > RX_MAXIOVECS)
        osi_Panic("osi_NetReceive: %d: too many iovecs\n", nvecs);
 
@@ -92,6 +95,9 @@ osi_NetSend(osi_socket asocket, struct sockaddr_in *addr, struct iovec *dvec,
     struct mbuf *nam;
     int haveGlock = ISAFS_GLOCK();
 
+    memset(&u, 0, sizeof(u));
+    memset(&iov, 0, sizeof(iov));
+
     AFS_STATCNT(osi_NetSend);
     if (nvecs > RX_MAXIOVECS)
        osi_Panic("osi_NetSend: %d: Too many iovecs.\n", nvecs);
index 85e21ee8aa3ff4ba4b56628cd59357873a6a6f31..101356b3963e17d96cd09f3898f63d57f7edc6ac 100644 (file)
@@ -484,6 +484,9 @@ osi_NetSend(osi_socket asocket, struct sockaddr_in *addr, struct iovec *dvec,
     int error;
     int i;
 
+    memset(&uio, 0, sizeof(uio));
+    memset(&iov, 0, sizeof(iov));
+
     if (nvecs > RX_MAXIOVECS) {
        osi_Panic("osi_NetSend: %d: Too many iovecs.\n", nvecs);
     }
@@ -524,6 +527,9 @@ osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
     int error;
     int i;
 
+    memset(&uio, 0, sizeof(uio));
+    memset(&iov, 0, sizeof(iov));
+
     if (nvecs > RX_MAXIOVECS) {
        osi_Panic("osi_NetSend: %d: Too many iovecs.\n", nvecs);
     }