]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE12-fix-netreceive-memleak-20030130
authorJim Rees <rees@umich.edu>
Fri, 31 Jan 2003 21:20:25 +0000 (21:20 +0000)
committerDerrick Brashear <shadow@dementia.org>
Fri, 31 Jan 2003 21:20:25 +0000 (21:20 +0000)
for darwin and freebsd, simplified for pullup

(cherry picked from commit 530c491c673154c5c935bd339c6d00850d454190)

src/rx/DARWIN/rx_knet.c
src/rx/FBSD/rx_knet.c

index f069eed1ca2a786914d9d36cf987efb2e3d7694a..87549ff1298c35b95b88d669c6c78c4e86310f7a 100644 (file)
@@ -24,7 +24,7 @@ int osi_NetReceive(asocket, addr, dvec, nvecs, alength)
     struct uio u;
     int i;
     struct iovec iov[RX_MAXIOVECS];
-    struct sockaddr *sa;
+    struct sockaddr *sa = NULL;
     int code;
 
     int haveGlock = ISAFS_GLOCK();
@@ -60,13 +60,16 @@ int osi_NetReceive(asocket, addr, dvec, nvecs, alength)
     if (haveGlock) {
         AFS_GLOCK();
     }
-    *alength=*alength-u.uio_resid;
+    if (code)
+       return code;
+    *alength -= u.uio_resid;
     if (sa) {
        if (sa->sa_family == AF_INET) {
           if (addr) *addr=*(struct sockaddr_in *)sa;
        } else {
           printf("Unknown socket family %d in NetReceive\n");
        }
+       FREE(sa, M_SONAME);
     }
     return code;
 }
index 6a736e2afdab286c817725f556132ab8845c74b9..fc50c34af136232a3393c33c289acce0a3d36746 100644 (file)
@@ -26,6 +26,7 @@
 RCSID("$Header$");
 
 #ifdef AFS_FBSD40_ENV
+#include <sys/malloc.h>
 #include "../rx/rx_kcommon.h"
 
 
@@ -37,7 +38,7 @@ int osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
     struct uio u;
     int i;
     struct iovec iov[RX_MAXIOVECS];
-    struct sockaddr *sa;
+    struct sockaddr *sa = NULL;
     int code;
 
     int haveGlock = ISAFS_GLOCK();
@@ -75,13 +76,16 @@ int osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
     if (haveGlock) {
         AFS_GLOCK();
     }
-    *alength=*alength-u.uio_resid;
+    if (code)
+       return code;
+    *alength -= u.uio_resid;
     if (sa) {
        if (sa->sa_family == AF_INET) {
           if (addr) *addr=*(struct sockaddr_in *)sa;
        } else {
           printf("Unknown socket family %d in NetReceive\n", sa->sa_family);
        }
+       FREE(sa, M_SONAME);
     }
     return code;
 }
@@ -141,7 +145,8 @@ osi_NetSend(asocket, addr, dvec, nvecs, alength, istack)
 #if KNET_DEBUG
     printf("+");
 #endif
-    code = sosend(asocket, addr, &u, NULL, NULL, 0, curproc);
+    code = sosend(asocket, (struct sockaddr *)addr, &u, NULL, NULL, 0, 
+                 curproc);
 #if KNET_DEBUG
     if (code) {
         if (code == EINVAL)