[git] GnuPG - branch, master, updated. gnupg-2.1.1-57-g7db6c82

by Joshua Rogers cvs at cvs.gnupg.org
Fri Jan 30 03:50:08 CET 2015


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 "The GNU Privacy Guard".

The branch, master has been updated
       via  7db6c82cec49b7c56c403a8ea98364086baf75f3 (commit)
      from  6ab0fac575a8b04152a199cb300a08436b096753 (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 7db6c82cec49b7c56c403a8ea98364086baf75f3
Author: Joshua Rogers <git at internot.info>
Date:   Fri Jan 30 11:42:52 2015 +0900

    kbx: Fix resource leak.
    
    * kbx/keybox-update.c (blob_filecopy): Fix resource leak.  On error
    return, 'fp' and 'newfp' was never closed.
    
    --
    
    Signed-off-by: Joshua Rogers <git at internot.info>
    
    [Log entry reformatted, and added more fixes - gniibe]

diff --git a/kbx/keybox-update.c b/kbx/keybox-update.c
index 11861ac..7b207a5 100644
--- a/kbx/keybox-update.c
+++ b/kbx/keybox-update.c
@@ -241,11 +241,17 @@ blob_filecopy (int mode, const char *fname, KEYBOXBLOB blob,
 
       rc = _keybox_write_header_blob (newfp, for_openpgp);
       if (rc)
-        return rc;
+        {
+          fclose (newfp);
+          return rc;
+        }
 
       rc = _keybox_write_blob (blob, newfp);
       if (rc)
-        return rc;
+        {
+          fclose (newfp);
+          return rc;
+        }
 
       if ( fclose (newfp) )
         return gpg_error_from_syserror ();
@@ -268,7 +274,8 @@ blob_filecopy (int mode, const char *fname, KEYBOXBLOB blob,
   rc = create_tmp_file (fname, &bakfname, &tmpfname, &newfp);
   if (rc)
     {
-      fclose(fp);
+      fclose (fp);
+      fclose (newfp);
       goto leave;
     }
 
@@ -292,12 +299,16 @@ blob_filecopy (int mode, const char *fname, KEYBOXBLOB blob,
           if (fwrite (buffer, nread, 1, newfp) != 1)
             {
               rc = gpg_error_from_syserror ();
+              fclose (fp);
+              fclose (newfp);
               goto leave;
             }
         }
       if (ferror (fp))
         {
           rc = gpg_error_from_syserror ();
+          fclose (fp);
+          fclose (newfp);
           goto leave;
         }
     }
@@ -321,19 +332,27 @@ blob_filecopy (int mode, const char *fname, KEYBOXBLOB blob,
           if (fwrite (buffer, nread, 1, newfp) != 1)
             {
               rc = gpg_error_from_syserror ();
+              fclose (fp);
+              fclose (newfp);
               goto leave;
             }
         }
       if (ferror (fp))
         {
           rc = gpg_error_from_syserror ();
+          fclose (fp);
+          fclose (newfp);
           goto leave;
         }
 
       /* Skip this blob. */
       rc = _keybox_read_blob (NULL, fp);
       if (rc)
-        return rc;
+        {
+          fclose (fp);
+          fclose (newfp);
+          return rc;
+        }
     }
 
   /* Do an insert or update. */
@@ -341,7 +360,11 @@ blob_filecopy (int mode, const char *fname, KEYBOXBLOB blob,
     {
       rc = _keybox_write_blob (blob, newfp);
       if (rc)
+        {
+          fclose (fp);
+          fclose (newfp);
           return rc;
+        }
     }
 
   /* Copy the rest of the packet for an delete or update. */
@@ -352,12 +375,16 @@ blob_filecopy (int mode, const char *fname, KEYBOXBLOB blob,
           if (fwrite (buffer, nread, 1, newfp) != 1)
             {
               rc = gpg_error_from_syserror ();
+              fclose (fp);
+              fclose (newfp);
               goto leave;
             }
         }
       if (ferror (fp))
         {
           rc = gpg_error_from_syserror ();
+          fclose (fp);
+          fclose (newfp);
           goto leave;
         }
     }
@@ -726,7 +753,7 @@ keybox_compress (KEYBOX_HANDLE hd)
   rc = create_tmp_file (fname, &bakfname, &tmpfname, &newfp);
   if (rc)
     {
-      fclose(fp);
+      fclose (fp);
       return rc;;
     }
 

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

Summary of changes:
 kbx/keybox-update.c | 37 ++++++++++++++++++++++++++++++++-----
 1 file changed, 32 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list