Skip to contentSkip to conversation

Fix memory leak in auth-pam plugin

PATCH In review Steffan Karger 3 participants 3 messages Oct 20, 2015 – Oct 22, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix memory leak in auth-pam plugin

As it says on the tin. aresp would not be free'd nor returned by my_conv() on errors. Note that we never reach this code if allocation of aresp failed.

Found with the Clang static analyzer.

---
 src/plugins/auth-pam/auth-pam.c | 3 +++
 1 file changed, 3 insertions(+)
src/plugins/auth-pam/auth-pam.c +3 -0
index bd71792..95692ab 100644
@@ -642,6 +642,9 @@ my_conv (int n, const struct pam_message **msg_array,
 
   if (ret == PAM_SUCCESS)
     *response_array = aresp;
+  else
+    free(aresp);
+
   return ret;
 }
 
Signature · 1 line
2.1.4
#1 lore raw

ACK from me. My Clang static analyzer concurs.

Quoted 26 lines · Steffan Karger

As it says on the tin. aresp would not be free'd nor returned by my_conv() on errors. Note that we never reach this code if allocation of aresp failed.

Found with the Clang static analyzer.

---
  src/plugins/auth-pam/auth-pam.c | 3 +++
  1 file changed, 3 insertions(+)
src/plugins/auth-pam/auth-pam.c +3 -0
index bd71792..95692ab 100644
@@ -642,6 +642,9 @@ my_conv (int n, const struct pam_message **msg_array,
 
    if (ret == PAM_SUCCESS)
      *response_array = aresp;
+  else
+    free(aresp);
+
    return ret;
  }
 
#2 lore raw
In reply to Steffan Karger

Your patch has been applied to the master and release/2.3 branch.

commit cfc13b38bc6504b9768e4cc43311807d6b074672 (master) commit 6a5e978085cc721bb09796ab44d77c3142b5f78b (release/2.3)

Author: Steffan Karger
Date:   Wed Oct 21 00:38:26 2015 +0200
     Fix memory leak in auth-pam plugin

     Signed-off-by: Steffan Karger <[email protected]...>
     Acked-by: Lev Stipakov <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/10338
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering