[svn] GnuPG - r4757 - in trunk: . kbx keyserver po sm

svn author wk cvs at cvs.gnupg.org
Tue May 6 16:03:56 CEST 2008


Author: wk
Date: 2008-05-06 16:03:36 +0200 (Tue, 06 May 2008)
New Revision: 4757

Modified:
   trunk/TODO
   trunk/autogen.sh
   trunk/configure.ac
   trunk/kbx/ChangeLog
   trunk/kbx/keybox-blob.c
   trunk/kbx/keybox-file.c
   trunk/kbx/keybox-search.c
   trunk/kbx/keybox-update.c
   trunk/keyserver/gpgkeys_kdns.c
   trunk/po/ChangeLog
   trunk/po/be.po
   trunk/po/ca.po
   trunk/po/cs.po
   trunk/po/da.po
   trunk/po/de.po
   trunk/po/el.po
   trunk/po/eo.po
   trunk/po/es.po
   trunk/po/et.po
   trunk/po/fi.po
   trunk/po/fr.po
   trunk/po/gl.po
   trunk/po/hu.po
   trunk/po/id.po
   trunk/po/it.po
   trunk/po/ja.po
   trunk/po/nb.po
   trunk/po/pl.po
   trunk/po/pt.po
   trunk/po/pt_BR.po
   trunk/po/ro.po
   trunk/po/ru.po
   trunk/po/sk.po
   trunk/po/sv.po
   trunk/po/tr.po
   trunk/po/zh_CN.po
   trunk/po/zh_TW.po
   trunk/sm/ChangeLog
   trunk/sm/keylist.c
Log:
Fixed bug#907.
Fixed a segv in keybox and made it more robust.


[The diff below has been truncated]

Modified: trunk/kbx/ChangeLog
===================================================================
--- trunk/kbx/ChangeLog	2008-05-06 11:05:52 UTC (rev 4756)
+++ trunk/kbx/ChangeLog	2008-05-06 14:03:36 UTC (rev 4757)
@@ -1,3 +1,12 @@
+2008-05-06  Werner Koch  <wk at g10code.com>
+
+	* keybox-file.c (_keybox_read_blob2): Return GPG_ERR_TOO_SHORT if
+	we get an EOF for 2nd to 5th byte as a better error message.
+
+	Always use gpg_error_from_syserror and gpg_err_code_from_syserror.
+	This is to avoid cases where we expect an error but due to an
+	errno set to 0 we get back a success status.
+
 2008-04-01  Werner Koch  <wk at g10code.com>
 
 	* keybox-init.c (keybox_new, keybox_release): Track used handles.

Modified: trunk/po/ChangeLog
===================================================================
--- trunk/po/ChangeLog	2008-05-06 11:05:52 UTC (rev 4756)
+++ trunk/po/ChangeLog	2008-05-06 14:03:36 UTC (rev 4757)
@@ -1,3 +1,7 @@
+2008-05-01  Werner Koch  <wk at g10code.com>
+
+	* de.po: Typo fix.
+
 2008-03-26  Jedi Lin <Jedi at Jedi.org>  (wk)
 
 	* zh_TW.po: Update.

Modified: trunk/sm/ChangeLog
===================================================================
--- trunk/sm/ChangeLog	2008-05-06 11:05:52 UTC (rev 4756)
+++ trunk/sm/ChangeLog	2008-05-06 14:03:36 UTC (rev 4757)
@@ -1,3 +1,8 @@
+2008-05-06  Werner Koch  <wk at g10code.com>
+
+	* keylist.c (list_external_keys): Ignore NOT FOUND error code.
+	This is bug#907.
+
 2008-04-23  Werner Koch  <wk at g10code.com>
 
 	* certchain.c (find_up): Make correct C89 code.  Declare variable

Modified: trunk/TODO
===================================================================
--- trunk/TODO	2008-05-06 11:05:52 UTC (rev 4756)
+++ trunk/TODO	2008-05-06 14:03:36 UTC (rev 4757)
@@ -131,4 +131,6 @@
   our design goal to allow changing the locale without changing
   gpg-agent's default locale (e.g. by the command updatestartuptty).
 
+* RFC 4387: Operational Protocols: Certificate Store Access via HTTP
+  Do we support this?
 

Modified: trunk/autogen.sh
===================================================================
--- trunk/autogen.sh	2008-05-06 11:05:52 UTC (rev 4756)
+++ trunk/autogen.sh	2008-05-06 14:03:36 UTC (rev 4757)
@@ -93,6 +93,7 @@
 	     --with-zlib=${w32root} \
 	     --with-regex=${w32root} \
              --with-pth-prefix=${w32root} \
+             --with-adns=${w32root}
              --without-included-gettext "$@"
     rc=$?
     exit $rc

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2008-05-06 11:05:52 UTC (rev 4756)
+++ trunk/configure.ac	2008-05-06 14:03:36 UTC (rev 4757)
@@ -847,6 +847,8 @@
   ADNSLIBS="-ladns" 
 fi
 AC_SUBST(ADNSLIBS)
+# Newer adns versions feature a free function to be used under W32.
+AC_CHECK_FUNCS(adns_free)
 
 
 #

Modified: trunk/kbx/keybox-blob.c
===================================================================
--- trunk/kbx/keybox-blob.c	2008-05-06 11:05:52 UTC (rev 4756)
+++ trunk/kbx/keybox-blob.c	2008-05-06 14:03:36 UTC (rev 4757)
@@ -685,7 +685,7 @@
 
   pp = xtrymalloc (n);
   if ( !pp )
-    return gpg_error (gpg_err_code_from_errno (errno));
+    return gpg_error_from_syserror ();
   memcpy (pp , p, n);
   blob->blob = pp;
   blob->bloblen = n;
@@ -706,7 +706,7 @@
   *r_blob = NULL;
   blob = xtrycalloc (1, sizeof *blob);
   if (!blob)
-    return gpg_error (gpg_err_code_from_errno (errno));
+    return gpg_error_from_syserror ();
 
   /* fixme: Do some sanity checks on the keyblock */
 
@@ -838,7 +838,7 @@
   *r_blob = NULL;
   blob = xtrycalloc (1, sizeof *blob);
   if( !blob )
-    return gpg_error (gpg_err_code_from_errno (errno));
+    return gpg_error_from_syserror ();
 
   sn = ksba_cert_get_serial (cert);
   if (sn)
@@ -873,7 +873,7 @@
   names = xtrymalloc (max_names * sizeof *names);
   if (!names)
     {
-      rc = gpg_error (gpg_err_code_from_errno (errno));
+      rc = gpg_error_from_syserror ();
       goto leave;
     }
   
@@ -894,7 +894,7 @@
           tmp = xtryrealloc (names, max_names * sizeof *names);
           if (!tmp)
             {
-              rc = gpg_error (gpg_err_code_from_errno (errno));
+              rc = gpg_error_from_syserror ();
               goto leave;
             }
         }
@@ -985,7 +985,7 @@
   *r_blob = NULL;
   blob = xtrycalloc (1, sizeof *blob);
   if (!blob)
-    return gpg_error (gpg_err_code_from_errno (errno));
+    return gpg_error_from_syserror ();
 
   blob->blob = image;
   blob->bloblen = imagelen;

Modified: trunk/kbx/keybox-file.c
===================================================================
--- trunk/kbx/keybox-file.c	2008-05-06 11:05:52 UTC (rev 4756)
+++ trunk/kbx/keybox-file.c	2008-05-06 14:03:36 UTC (rev 4757)
@@ -58,7 +58,7 @@
   *r_blob = NULL;
   off = ftello (fp);
   if (off == (off_t)-1)
-    return gpg_error (gpg_err_code_from_errno (errno));
+    return gpg_error_from_syserror ();
 
   if ((c1 = getc (fp)) == EOF
       || (c2 = getc (fp)) == EOF
@@ -68,7 +68,9 @@
     {
       if ( c1 == EOF && !ferror (fp) )
         return -1; /* eof */
-      return gpg_error (gpg_err_code_from_errno (errno));
+      if (!ferror (fp))
+        return gpg_error (GPG_ERR_TOO_SHORT);
+      return gpg_error_from_syserror ();
     }
 
   imagelen = (c1 << 24) | (c2 << 16) | (c3 << 8 ) | c4;
@@ -82,26 +84,26 @@
     {
       /* Special treatment for empty blobs. */
       if (fseek (fp, imagelen-5, SEEK_CUR))
-        return gpg_error (gpg_err_code_from_errno (errno));
+        return gpg_error_from_syserror ();
       *skipped_deleted = 1;
       goto again;
     }
 
   image = xtrymalloc (imagelen);
   if (!image) 
-    return gpg_error (gpg_err_code_from_errno (errno));
+    return gpg_error_from_syserror ();
 
   image[0] = c1; image[1] = c2; image[2] = c3; image[3] = c4; image[4] = type;
   if (fread (image+5, imagelen-5, 1, fp) != 1)
     {
-      gpg_error_t tmperr = gpg_error (gpg_err_code_from_errno (errno));
+      gpg_error_t tmperr = gpg_error_from_syserror ();
       xfree (image);
       return tmperr;
     }
   
   rc = r_blob? _keybox_new_blob (r_blob, image, imagelen, off) : 0;
   if (rc || !r_blob)
-        xfree (image);
+    xfree (image);
   return rc;
 }
 
@@ -122,7 +124,7 @@
 
   image = _keybox_get_blob_image (blob, &length);
   if (fwrite (image, length, 1, fp) != 1)
-    return gpg_error (gpg_err_code_from_errno (errno));
+    return gpg_error_from_syserror ();
   return 0;
 }
 
@@ -154,7 +156,7 @@
   image[20+3] = (val      );
 
   if (fwrite (image, 32, 1, fp) != 1)
-    return gpg_error (gpg_err_code_from_errno (errno));
+    return gpg_error_from_syserror ();
   return 0;
 }
 

Modified: trunk/kbx/keybox-search.c
===================================================================
--- trunk/kbx/keybox-search.c	2008-05-06 11:05:52 UTC (rev 4756)
+++ trunk/kbx/keybox-search.c	2008-05-06 14:03:36 UTC (rev 4757)
@@ -735,7 +735,7 @@
         {
           sn_array = xtrycalloc (ndesc, sizeof *sn_array);
           if (!sn_array)
-            return (hd->error = gpg_error (gpg_err_code_from_errno (errno)));
+            return (hd->error = gpg_error_from_syserror ());
         }
     }
 
@@ -744,7 +744,7 @@
       hd->fp = fopen (hd->kb->fname, "rb");
       if (!hd->fp)
         {
-          hd->error = gpg_error (gpg_err_code_from_errno (errno));
+          hd->error = gpg_error_from_syserror ();
           xfree (sn_array);
           return hd->error;
         }
@@ -776,7 +776,7 @@
               sn_array[n].sn = xtrymalloc (snlen);
               if (!sn_array[n].sn)
                 {
-                  hd->error = gpg_error (gpg_err_code_from_errno (errno));
+                  hd->error = gpg_error_from_syserror ();
                   release_sn_array (sn_array, n);
                   return hd->error;
                 }
@@ -800,7 +800,7 @@
               sn_array[n].sn = xtrymalloc (snlen);
               if (!sn_array[n].sn)
                 {
-                  hd->error = gpg_error (gpg_err_code_from_errno (errno));
+                  hd->error = gpg_error_from_syserror ();
                   release_sn_array (sn_array, n);
                   return hd->error;
                 }

Modified: trunk/kbx/keybox-update.c
===================================================================
--- trunk/kbx/keybox-update.c	2008-05-06 11:05:52 UTC (rev 4756)
+++ trunk/kbx/keybox-update.c	2008-05-06 14:03:36 UTC (rev 4757)
@@ -82,14 +82,14 @@
     {
       bakfname = xtrymalloc (strlen (template) + 1);
       if (!bakfname)
-        return gpg_error (gpg_err_code_from_errno (errno));
+        return gpg_error_from_syserror ();
       strcpy (bakfname, template);
       strcpy (bakfname+strlen(template)-4, EXTSEP_S "bak");
       
       tmpfname = xtrymalloc (strlen (template) + 1);
       if (!tmpfname)
         {
-          gpg_error_t tmperr = gpg_error (gpg_err_code_from_errno (errno));
+          gpg_error_t tmperr = gpg_error_from_syserror ();
           xfree (bakfname);
           return tmperr;
         }
@@ -100,13 +100,13 @@
     { /* File does not end with kbx; hmmm. */
       bakfname = xtrymalloc ( strlen (template) + 5);
       if (!bakfname)
-        return gpg_error (gpg_err_code_from_errno (errno));
+        return gpg_error_from_syserror ();
       strcpy (stpcpy (bakfname, template), EXTSEP_S "bak");
       
       tmpfname = xtrymalloc ( strlen (template) + 5);
       if (!tmpfname)
         {
-          gpg_error_t tmperr = gpg_error (gpg_err_code_from_errno (errno));
+          gpg_error_t tmperr = gpg_error_from_syserror ();
           xfree (bakfname);
           return tmperr;
         }
@@ -115,13 +115,13 @@
 # else /* Posix file names */
   bakfname = xtrymalloc (strlen (template) + 2);
   if (!bakfname)
-    return gpg_error (gpg_err_code_from_errno (errno));
+    return gpg_error_from_syserror ();
   strcpy (stpcpy (bakfname,template),"~");
   
   tmpfname = xtrymalloc ( strlen (template) + 5);
   if (!tmpfname)
     {
-      gpg_error_t tmperr = gpg_error (gpg_err_code_from_errno (errno));
+      gpg_error_t tmperr = gpg_error_from_syserror ();
       xfree (bakfname);
       return tmperr;
     }
@@ -131,7 +131,7 @@
   *r_fp = fopen (tmpfname, "wb");
   if (!*r_fp)
     {
-      gpg_error_t tmperr = gpg_error (gpg_err_code_from_errno (errno));
+      gpg_error_t tmperr = gpg_error_from_syserror ();
       xfree (tmpfname);
       xfree (bakfname);
       return tmperr;
@@ -175,7 +175,7 @@
 #endif
       if (rename (fname, bakfname) )
         {
-          return gpg_error (gpg_err_code_from_errno (errno));
+          return gpg_error_from_syserror ();
 	}
     }
   
@@ -185,7 +185,7 @@
 #endif
   if (rename (tmpfname, fname) )
     {
-      rc = gpg_error (gpg_err_code_from_errno (errno));
+      rc = gpg_error_from_syserror ();
       if (secret)
         {
 /*            log_info ("WARNING: 2 files with confidential" */
@@ -221,7 +221,7 @@
   /* Open the source file. Because we do a rename, we have to check the 
      permissions of the file */
   if (access (fname, W_OK))
-    return gpg_error (gpg_err_code_from_errno (errno));
+    return gpg_error_from_syserror ();
 
   fp = fopen (fname, "rb");
   if (mode == 1 && !fp && errno == ENOENT)
@@ -230,7 +230,7 @@
          Create a new keybox file. */
       newfp = fopen (fname, "wb");
       if (!newfp )
-        return gpg_error (gpg_err_code_from_errno (errno));
+        return gpg_error_from_syserror ();
 
       rc = _keybox_write_header_blob (newfp);
       if (rc)
@@ -241,7 +241,7 @@
         return rc;
 
       if ( fclose (newfp) )
-        return gpg_error (gpg_err_code_from_errno (errno));
+        return gpg_error_from_syserror ();
 
 /*        if (chmod( fname, S_IRUSR | S_IWUSR )) */
 /*          { */
@@ -253,7 +253,7 @@
 
   if (!fp)
     {
-      rc = gpg_error (gpg_err_code_from_errno (errno));
+      rc = gpg_error_from_syserror ();
       goto leave;
     }
 
@@ -273,13 +273,13 @@
         {
           if (fwrite (buffer, nread, 1, newfp) != 1)
             {
-              rc = gpg_error (gpg_err_code_from_errno (errno));
+              rc = gpg_error_from_syserror ();
               goto leave;
             }
         }
       if (ferror (fp))
         {
-          rc = gpg_error (gpg_err_code_from_errno (errno));
+          rc = gpg_error_from_syserror ();
           goto leave;
         }
     }
@@ -302,13 +302,13 @@
           
           if (fwrite (buffer, nread, 1, newfp) != 1)
             {
-              rc = gpg_error (gpg_err_code_from_errno (errno));
+              rc = gpg_error_from_syserror ();
               goto leave;
             }
         }
       if (ferror (fp))
         {
-          rc = gpg_error (gpg_err_code_from_errno (errno));
+          rc = gpg_error_from_syserror ();
           goto leave;
         }
       
@@ -333,13 +333,13 @@
         {
           if (fwrite (buffer, nread, 1, newfp) != 1)
             {
-              rc = gpg_error (gpg_err_code_from_errno (errno));
+              rc = gpg_error_from_syserror ();
               goto leave;
             }
         }
       if (ferror (fp))
         {
-          rc = gpg_error (gpg_err_code_from_errno (errno));
+          rc = gpg_error_from_syserror ();
           goto leave;
         }
     }
@@ -347,13 +347,13 @@
   /* Close both files. */
   if (fclose(fp))
     {
-      rc = gpg_error (gpg_err_code_from_errno (errno));
+      rc = gpg_error_from_syserror ();
       fclose (newfp);
       goto leave;
     }
   if (fclose(newfp))
     {
-      rc = gpg_error (gpg_err_code_from_errno (errno));
+      rc = gpg_error_from_syserror ();
       goto leave;
     }
 
@@ -452,11 +452,11 @@
   _keybox_close_file (hd);
   fp = fopen (hd->kb->fname, "r+b");
   if (!fp)
-    return gpg_error (gpg_err_code_from_errno (errno));
+    return gpg_error_from_syserror ();
 
   ec = 0;
   if (fseeko (fp, off, SEEK_SET))
-    ec = gpg_error (gpg_err_code_from_errno (errno));
+    ec = gpg_error_from_syserror ();
   else
     {
       unsigned char tmp[4];
@@ -472,7 +472,7 @@
         case 2:
         case 4:
           if (fwrite (tmp+4-flag_size, flag_size, 1, fp) != 1)
-            ec = gpg_err_code_from_errno (errno);
+            ec = gpg_err_code_from_syserror ();
           break;
         default:
           ec = GPG_ERR_BUG;
@@ -483,7 +483,7 @@
   if (fclose (fp))
     {
       if (!ec)
-        ec = gpg_err_code_from_errno (errno);
+        ec = gpg_err_code_from_syserror ();
     }
 
   return gpg_error (ec);
@@ -517,19 +517,19 @@
   _keybox_close_file (hd);
   fp = fopen (hd->kb->fname, "r+b");
   if (!fp)
-    return gpg_error (gpg_err_code_from_errno (errno));
+    return gpg_error_from_syserror ();
 
   if (fseeko (fp, off, SEEK_SET))
-    rc = gpg_error (gpg_err_code_from_errno (errno));
+    rc = gpg_error_from_syserror ();
   else if (putc (0, fp) == EOF)
-    rc = gpg_error (gpg_err_code_from_errno (errno));
+    rc = gpg_error_from_syserror ();
   else
     rc = 0;
 
   if (fclose (fp))
     {
       if (!rc)
-        rc = gpg_error (gpg_err_code_from_errno (errno));
+        rc = gpg_error_from_syserror ();
     }
 
   return rc;
@@ -567,14 +567,14 @@
   /* Open the source file. Because we do a rename, we have to check the 
      permissions of the file */
   if (access (fname, W_OK))
-    return gpg_error (gpg_err_code_from_errno (errno));
+    return gpg_error_from_syserror ();
 
   fp = fopen (fname, "rb");
   if (!fp && errno == ENOENT)
     return 0; /* Ready. File has been deleted right after the access above. */
   if (!fp)
     {
-      rc = gpg_error (gpg_err_code_from_errno (errno));
+      rc = gpg_error_from_syserror ();
       return rc;
     }
 
@@ -695,9 +695,9 @@
 
   /* Close both files. */
   if (fclose(fp) && !rc)
-    rc = gpg_error (gpg_err_code_from_errno (errno));
+    rc = gpg_error_from_syserror ();
   if (fclose(newfp) && !rc)
-    rc = gpg_error (gpg_err_code_from_errno (errno));
+    rc = gpg_error_from_syserror ();
 
   /* Rename or remove the temporary file. */
   if (rc || !any_changes)

Modified: trunk/keyserver/gpgkeys_kdns.c
===================================================================
--- trunk/keyserver/gpgkeys_kdns.c	2008-05-06 11:05:52 UTC (rev 4756)
+++ trunk/keyserver/gpgkeys_kdns.c	2008-05-06 14:03:36 UTC (rev 4757)
@@ -29,6 +29,9 @@
 #include <assert.h>
 #ifdef HAVE_ADNS_H
 # include <adns.h>
+# ifndef HAVE_ADNS_FREE
+#  define adns_free free
+# endif
 #endif
 
 #define INCLUDED_BY_MAIN_MODULE 1
@@ -175,7 +178,7 @@
     fprintf (output, "\nNAME %s FAILED %d\n", address, ret);
   else
     fprintf (output, "\nNAME %s END\n", address);
-  free (answer);  /* (Right, this is free and not xfree.) */
+  adns_free (answer); 
   xfree (name);




More information about the Gnupg-commits mailing list