[mod_gnutls-devel] msv_ctxt_init() cleanup

Ramkumar Chinchani ramkumar.chinchani at gmail.com
Tue Mar 18 23:06:34 CET 2014


Yes, this is a libmsv patch (can post in a different forum in future should
Clint prefer so)

And the following is not needed.
> +#include <signal.h>

The following is the final patch in the current series I am working on for
libmsv.
Also running valgrind (with limited testing) shows that there are no memory
leaks now.

cURL's WRITEFUNCTION is only called when there is data, so returning a ZERO
when malloc fails should cause a write abort [1]

[1] http://curl.haxx.se/libcurl/c/curl_easy_setopt.html

Thanks.

diff --git a/msv.c b/msv.c
index bd23c0a..fcc55a6 100644
--- a/msv.c
+++ b/msv.c
@@ -64,6 +64,8 @@ write_function (void *ptr, size_t size, size_t nmemb,
void *userdata)
   char *ud;

   ud = malloc (size * nmemb + 1);
+  if (!ud)
+      return 0;
   memcpy (ud, ptr, size * nmemb);

   ud[size * nmemb] = '\0';
@@ -292,6 +294,12 @@ msv_query_agent (msv_ctxt_t ctx, struct msv_query q,

   oldurllen = strlen (ctx->socket_location);
   reviewurl = malloc (oldurllen + 12);
+  if (!reviewurl)
+    {
+        curl_easy_cleanup (c);
+        free (req);
+        return LIBMSV_ERROR_NOMEM;
+    }
   sprintf (reviewurl, "%s%s", ctx->socket_location, "/reviewcert");

   cc = curl_easy_setopt (c, CURLOPT_URL, reviewurl);



On Tue, Mar 18, 2014 at 2:18 PM, Daniel Kahn Gillmor
<dkg at fifthhorseman.net>wrote:

> Hi Ramkumar--
>
> I think the message below is about libmsv, not mod_gnutls, right?
>
> I'm fine using this mailing list to discuss libmsv work (though if Clint
> would prefer it happen somewhere else, i defer to his preference), but
> please make it clear which project a patch applies to in the message
> someplace to avoid confusion.
>
> (one comment inline, below)
>
> On 03/18/2014 05:09 PM, Ramkumar Chinchani wrote:
> > Test code cleanup after recent code changes.
> >
> > diff --git a/checkmsva.c b/checkmsva.c
> > index 1c64977..aaa3133 100644
> > --- a/checkmsva.c
> > +++ b/checkmsva.c
> > @@ -17,6 +17,7 @@
> >
> >  #include <stdlib.h>
> >  #include <stdio.h>
> > +#include <signal.h>
> >
> >  #include "msv/msv.h"
> >
>
> signal.h doesn't seem to be needed by the rest of this patch; does it
> belong in a different changeset?
>
> Thanks for your attention to detail, keep these patches coming!
>
> Regards,
>
>         --dkg
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/attachments/20140318/05cd82dd/attachment.html>


More information about the mod_gnutls-devel mailing list