[mod_gnutls-devel] msv_ctxt_init() cleanup

Ramkumar Chinchani ramkumar.chinchani at gmail.com
Thu Mar 13 22:01:00 CET 2014


This is a libmsv patch again. Sorry, couldn't find a better place to post
this.

Consequently, mod_gnutls code has to handle this error case now.

Also noticed that msv.c has a few more malloc's and strdup's without proper
out-of-memory handling.


diff --git a/msv.c b/msv.c
index b56b3a6..8ed4837 100644
--- a/msv.c
+++ b/msv.c
@@ -78,16 +78,28 @@ msv_ctxt_init (const char *url)
 {

   msv_ctxt_t ctx;
+  char *env;

   ctx = malloc (sizeof (struct msv_ctxt));
+  if (!ctx)
+    return NULL;

   if (url)
     ctx->socket_location = strdup (url);
-  else
+  else if ((env = getenv ("MONKEYSPHERE_VALIDATION_AGENT_SOCKET")))
+    ctx->socket_location = strdup (env);
+  else
+    {
+      free(ctx);
+      return NULL;
+    }
+
+  if (!ctx->socket_location)
     {
-      ctx->socket_location =
-       strdup (getenv ("MONKEYSPHERE_VALIDATION_AGENT_SOCKET"));
+      free(ctx);
+      return NULL;
     }
+
   return ctx;
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/attachments/20140313/a7e0138b/attachment.html>


More information about the mod_gnutls-devel mailing list