[git] Assuan - branch, master, updated. libassuan-2.4.2-3-gd60ef71

by Werner Koch cvs at cvs.gnupg.org
Sat Jun 25 17:01:07 CEST 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "IPC library used by GnuPG".

The branch, master has been updated
       via  d60ef7192ad95ec2ec1aef436742f56e6c750b89 (commit)
      from  7101fcbb662220326f2fc786219c1853f27a5298 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d60ef7192ad95ec2ec1aef436742f56e6c750b89
Author: Werner Koch <wk at gnupg.org>
Date:   Sat Jun 25 16:59:16 2016 +0200

    Fix minor memory leaks
    
    * src/assuan-pipe-connect.c (socketpair_connect): Always free
    CHILD_FDS.
    * src/assuan-uds.c (uds_sendfd): Clear CONTROL_U to silence Valgrind.
    * tests/fdpassing.c (main): Free FNAME.
    
    * src/assuan-handler.c (dispatch_command): Remove dead assignment.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/src/assuan-handler.c b/src/assuan-handler.c
index 351446d..dec0f1b 100644
--- a/src/assuan-handler.c
+++ b/src/assuan-handler.c
@@ -661,7 +661,7 @@ dispatch_command (assuan_context_t ctx, char *line, int linelen)
   if (!s)
     return PROCESS_DONE (ctx, set_error (ctx, GPG_ERR_ASS_UNKNOWN_CMD, NULL));
   line += shift;
-  linelen -= shift;
+  /* linelen -= shift; -- not needed.  */
 
   if (ctx->pre_cmd_notify_fnc) {
     err = ctx->pre_cmd_notify_fnc(ctx, ctx->cmdtbl[i].name);
diff --git a/src/assuan-pipe-connect.c b/src/assuan-pipe-connect.c
index e5d2a38..a657c94 100644
--- a/src/assuan-pipe-connect.c
+++ b/src/assuan-pipe-connect.c
@@ -347,10 +347,11 @@ socketpair_connect (assuan_context_t ctx,
 	fd_child_list[idx] = child_fds[idx + 1];
     }
 
+  _assuan_free (ctx, child_fds);
+
   /* If this is the server child process, exit early.  */
   if (! name && (*argv)[0] == 's')
     {
-      _assuan_free (ctx, child_fds);
       _assuan_close (ctx, fds[0]);
       return 0;
     }
diff --git a/src/assuan-uds.c b/src/assuan-uds.c
index dd77af4..59f3a6b 100644
--- a/src/assuan-uds.c
+++ b/src/assuan-uds.c
@@ -34,7 +34,7 @@
 #else
 # ifdef HAVE_WINSOCK2_H
 #  include <winsock2.h>
-# endif 
+# endif
 # include <windows.h>
 #endif
 #if HAVE_SYS_UIO_H
@@ -60,10 +60,10 @@
 #define MY_ALIGN(n) ((((n))+ sizeof(size_t)-1) & (size_t)~(sizeof(size_t)-1))
 #ifndef CMSG_SPACE
 #define CMSG_SPACE(n) (MY_ALIGN(sizeof(struct cmsghdr)) + MY_ALIGN((n)))
-#endif 
+#endif
 #ifndef CMSG_LEN
 #define CMSG_LEN(n) (MY_ALIGN(sizeof(struct cmsghdr)) + (n))
-#endif 
+#endif
 #ifndef CMSG_FIRSTHDR
 #define CMSG_FIRSTHDR(mhdr) \
   ((size_t)(mhdr)->msg_controllen >= sizeof (struct cmsghdr)		      \
@@ -200,12 +200,14 @@ uds_sendfd (assuan_context_t ctx, assuan_fd_t fd)
   char buffer[80];
 
   /* We need to send some real data so that a read won't return 0
-     which will be taken as an EOF.  It also helps with debugging. */ 
+     which will be taken as an EOF.  It also helps with debugging. */
   snprintf (buffer, sizeof(buffer)-1, "# descriptor %d is in flight\n", fd);
   buffer[sizeof(buffer)-1] = 0;
 
   memset (&msg, 0, sizeof (msg));
 
+  memset (&control_u, 0, sizeof (control_u));
+
   msg.msg_name = NULL;
   msg.msg_namelen = 0;
   msg.msg_iovlen = 1;
diff --git a/tests/fdpassing.c b/tests/fdpassing.c
index fee5ba0..1156ad7 100644
--- a/tests/fdpassing.c
+++ b/tests/fdpassing.c
@@ -59,10 +59,10 @@ cmd_echo (assuan_context_t ctx, char *line)
   nbytes = 0;
   while ( (c=getc (fp)) != -1)
     {
-      putc (c, stdout); 
+      putc (c, stdout);
       nbytes++;
     }
-  fflush (stdout); 
+  fflush (stdout);
   log_info ("done printing %d bytes to stdout\n", nbytes);
 
   fclose (fp);
@@ -118,7 +118,7 @@ server (void)
 
   assuan_set_log_stream (ctx, stderr);
 
-  for (;;) 
+  for (;;)
     {
       rc = assuan_accept (ctx);
       if (rc)
@@ -127,7 +127,7 @@ server (void)
             log_error ("assuan_accept failed: %s\n", gpg_strerror (rc));
           break;
         }
-      
+
       log_info ("client connected.  Client's pid is %ld\n",
                 (long)assuan_get_pid (ctx));
 
@@ -135,7 +135,7 @@ server (void)
       if (rc)
         log_error ("assuan_process failed: %s\n", gpg_strerror (rc));
     }
-  
+
   assuan_release (ctx);
 }
 
@@ -169,7 +169,7 @@ client (assuan_context_t ctx, const char *fname)
                      strerror (errno));
           return -1;
         }
-      
+
       rc = assuan_sendfd (ctx, fileno (fp));
       if (rc)
         {
@@ -204,12 +204,12 @@ client (assuan_context_t ctx, const char *fname)
 
 
 

-/* 
- 
+/*
+
      M A I N
 
 */
-int 
+int
 main (int argc, char **argv)
 {
   int last_argc = -1;
@@ -294,17 +294,18 @@ main (int argc, char **argv)
       if (err)
         {
           log_error ("assuan_pipe_connect failed: %s\n", gpg_strerror (err));
-          return 1;
+          assuan_release (ctx);
+          errorcount++;
         }
-      
-      if (!with_exec && loc[0] == 's')
+      else if (!with_exec && loc[0] == 's')
         {
           server ();
+          assuan_release (ctx);
           log_info ("server finished\n");
         }
       else
         {
-          if (client (ctx, fname)) 
+          if (client (ctx, fname))
             {
               log_info ("waiting for server to terminate...\n");
               assuan_release (ctx);
@@ -313,6 +314,7 @@ main (int argc, char **argv)
         }
     }
 
+  xfree (fname);
   return errorcount ? 1 : 0;
 }
 

-----------------------------------------------------------------------

Summary of changes:
 src/assuan-handler.c      |  2 +-
 src/assuan-pipe-connect.c |  3 ++-
 src/assuan-uds.c          | 10 ++++++----
 tests/fdpassing.c         | 28 +++++++++++++++-------------
 4 files changed, 24 insertions(+), 19 deletions(-)


hooks/post-receive
-- 
IPC library used by GnuPG
http://git.gnupg.org




More information about the Gnupg-commits mailing list