Source-Changes-HG archive

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

[src/trunk]: src/crypto/dist/ipsec-tools/src/racoon fix memory leaks: https:/...



details:   https://anonhg.NetBSD.org/src/rev/fe9725f774fa
branches:  trunk
changeset: 366469:fe9725f774fa
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Aug 28 09:10:28 2018 +0000

description:
fix memory leaks: https://github.com/NetBSD/src/issues/6

diffstat:

 crypto/dist/ipsec-tools/src/racoon/privsep.c |  21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diffs (102 lines):

diff -r 541bf0797ccb -r fe9725f774fa crypto/dist/ipsec-tools/src/racoon/privsep.c
--- a/crypto/dist/ipsec-tools/src/racoon/privsep.c      Tue Aug 28 08:50:46 2018 +0000
+++ b/crypto/dist/ipsec-tools/src/racoon/privsep.c      Tue Aug 28 09:10:28 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: privsep.c,v 1.24 2018/05/19 19:23:15 maxv Exp $        */
+/*     $NetBSD: privsep.c,v 1.25 2018/08/28 09:10:28 christos Exp $    */
 
 /* Id: privsep.c,v 1.15 2005/08/08 11:23:44 vanhu Exp */
 
@@ -917,7 +917,7 @@
        memcpy(msg + 1, path, msg->bufs.buflen[0]);
 
        if (privsep_send(privsep_sock[1], msg, len) != 0)
-               return NULL;
+               goto out;
 
        if (privsep_recv(privsep_sock[1], &msg, &len) != 0)
                return NULL;
@@ -1034,13 +1034,14 @@
         * And send it!
         */
        if (privsep_send(privsep_sock[1], msg, msg->hdr.ac_len) != 0)
-               return -1;
+               goto out;
 
        if (privsep_recv(privsep_sock[1], &msg, &len) != 0)
                return -1;
 
        if (msg->hdr.ac_errno != 0) {
                errno = msg->hdr.ac_errno;
+out:
                racoon_free(msg);
                return -1;
        }
@@ -1081,7 +1082,7 @@
        memcpy(data, &keylen, sizeof(keylen));
 
        if (privsep_send(privsep_sock[1], msg, len) != 0)
-               return NULL;
+               goto out;
 
        if (privsep_recv(privsep_sock[1], &msg, &len) != 0)
                return NULL;
@@ -1354,12 +1355,13 @@
        
        /* frees msg */
        if (privsep_send(privsep_sock[1], msg, len) != 0)
-               return -1;
+               goto out;
 
        if (privsep_recv(privsep_sock[1], &msg, &len) != 0)
                return -1;
 
        if (msg->hdr.ac_errno != 0) {
+out:
                racoon_free(msg);
                return -1;
        }
@@ -1416,7 +1418,7 @@
 
        /* frees msg */
        if (privsep_send(privsep_sock[1], msg, len) != 0)
-               return -1;
+               goto out;
 
        if (privsep_recv(privsep_sock[1], &msg, &len) != 0)
                return -1;
@@ -1664,7 +1666,7 @@
 
        /* frees msg */
        if (privsep_send(privsep_sock[1], msg, len) != 0)
-               return -1;
+               goto out;
 
        if (privsep_recv(privsep_sock[1], &msg, &len) != 0)
                return -1;
@@ -1734,7 +1736,7 @@
 
        /* frees msg */
        if (privsep_send(privsep_sock[1], msg, len) != 0)
-               return -1;
+               goto out;
 
        if (privsep_recv(privsep_sock[1], &msg, &len) != 0)
                return -1;
@@ -1786,7 +1788,7 @@
 
        /* frees msg */
        if (privsep_send(privsep_sock[1], msg, len) != 0)
-               return;
+               goto out;
 
        if (privsep_recv(privsep_sock[1], &msg, &len) != 0)
                return;
@@ -1794,6 +1796,7 @@
        if (msg->hdr.ac_errno != 0)
                errno = msg->hdr.ac_errno;
 
+out:
        racoon_free(msg);
        return;
 }



Home | Main Index | Thread Index | Old Index