[git] GnuPG - branch, master, updated. gnupg-2.1.2-95-g67158ff

by Werner Koch cvs at cvs.gnupg.org
Fri Apr 10 13:21:31 CEST 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  67158ff155ef52fd54a6bbe680551c0e12b31e69 (commit)
       via  0fb224c2c5e0c6770d4a6044d62d84f6bbc1b26b (commit)
       via  5d60c7f7e05a06e46e23bafe61cef09ad32aa998 (commit)
       via  f6670100b7a15b2071c2e4062f5c5a678f2a30f6 (commit)
       via  6ad95fe6f1f130c8f6d139a9bd57fc4a0d38292b (commit)
      from  9433661419043431a6cfc7d84c8450e0b2f6c353 (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 67158ff155ef52fd54a6bbe680551c0e12b31e69
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Apr 10 13:11:59 2015 +0200

    Remove obsolete directories from AM_CPPFLAGS.

diff --git a/agent/Makefile.am b/agent/Makefile.am
index bcf1788..b33593d 100644
--- a/agent/Makefile.am
+++ b/agent/Makefile.am
@@ -28,7 +28,7 @@ noinst_PROGRAMS = $(TESTS)
 EXTRA_DIST = ChangeLog-2011 gpg-agent-w32info.rc
 
 
-AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/common -I$(top_srcdir)/intl
+AM_CPPFLAGS = -I$(top_srcdir)/common
 
 include $(top_srcdir)/am/cmacros.am
 
diff --git a/common/Makefile.am b/common/Makefile.am
index 2ba6dc0..51923e8 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -34,7 +34,7 @@ BUILT_SOURCES = audit-events.h status-codes.h
 
 MAINTAINERCLEANFILES = audit-events.h status-codes.h
 
-AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/intl
+AM_CPPFLAGS =
 
 AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(LIBASSUAN_CFLAGS) $(KSBA_CFLAGS)
 
diff --git a/dirmngr/Makefile.am b/dirmngr/Makefile.am
index c8613bb..d80dd6d 100644
--- a/dirmngr/Makefile.am
+++ b/dirmngr/Makefile.am
@@ -30,7 +30,7 @@ endif
 noinst_PROGRAMS = $(module_tests)
 TESTS = $(module_tests)
 
-AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/common
+AM_CPPFLAGS = -I$(top_srcdir)/common
 
 include $(top_srcdir)/am/cmacros.am
 
diff --git a/g10/Makefile.am b/g10/Makefile.am
index 0a02119..b66abb8 100644
--- a/g10/Makefile.am
+++ b/g10/Makefile.am
@@ -21,8 +21,7 @@
 EXTRA_DIST = options.skel distsigkey.gpg ChangeLog-2011 gpg-w32info.rc \
 	     gpg.w32-manifest.in
 
-AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/common \
-              -I$(top_srcdir)/include -I$(top_srcdir)/intl
+AM_CPPFLAGS = -I$(top_srcdir)/common
 
 include $(top_srcdir)/am/cmacros.am
 
diff --git a/g13/Makefile.am b/g13/Makefile.am
index bbffe02..7d627cb 100644
--- a/g13/Makefile.am
+++ b/g13/Makefile.am
@@ -22,7 +22,7 @@ EXTRA_DIST = ChangeLog-2011
 
 bin_PROGRAMS = g13
 
-AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/common
+AM_CPPFLAGS = -I$(top_srcdir)/common
 
 include $(top_srcdir)/am/cmacros.am
 
diff --git a/kbx/Makefile.am b/kbx/Makefile.am
index eb434b6..5df2bba 100644
--- a/kbx/Makefile.am
+++ b/kbx/Makefile.am
@@ -20,8 +20,7 @@
 
 EXTRA_DIST = mkerrors
 
-AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/common \
-	      -I$(top_srcdir)/intl
+AM_CPPFLAGS = -I$(top_srcdir)/common
 
 include $(top_srcdir)/am/cmacros.am
 
diff --git a/scd/Makefile.am b/scd/Makefile.am
index f7217e3..6212e61 100644
--- a/scd/Makefile.am
+++ b/scd/Makefile.am
@@ -21,7 +21,7 @@ EXTRA_DIST = ChangeLog-2011 scdaemon-w32info.rc
 
 libexec_PROGRAMS = scdaemon
 
-AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/common
+AM_CPPFLAGS = -I$(top_srcdir)/common
 
 include $(top_srcdir)/am/cmacros.am
 
diff --git a/sm/Makefile.am b/sm/Makefile.am
index 7f6df3a..dda3eb8 100644
--- a/sm/Makefile.am
+++ b/sm/Makefile.am
@@ -23,7 +23,7 @@ bin_PROGRAMS = gpgsm
 
 AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(KSBA_CFLAGS) $(LIBASSUAN_CFLAGS)
 
-AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/common -I$(top_srcdir)/intl
+AM_CPPFLAGS = -I$(top_srcdir)/common
 include $(top_srcdir)/am/cmacros.am
 
 if HAVE_W32_SYSTEM
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 1ba0377..5c28954 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -23,7 +23,7 @@ EXTRA_DIST = \
 	ccidmon.c ChangeLog-2011 gpg-connect-agent-w32info.rc
 
 
-AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/common
+AM_CPPFLAGS = -I$(top_srcdir)/common
 include $(top_srcdir)/am/cmacros.am
 
 if HAVE_W32_SYSTEM

commit 0fb224c2c5e0c6770d4a6044d62d84f6bbc1b26b
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Apr 10 13:05:38 2015 +0200

    dirmngr,w32: Replace functions not available under Windows.
    
    * dirmngr/ks-engine-ldap.c (extract_attributes): Replace isoptime and
    gmtime_r.

diff --git a/dirmngr/ks-engine-ldap.c b/dirmngr/ks-engine-ldap.c
index 82d6234..aefd12a 100644
--- a/dirmngr/ks-engine-ldap.c
+++ b/dirmngr/ks-engine-ldap.c
@@ -1748,12 +1748,13 @@ extract_attributes (LDAPMod ***modlist, char *line)
 	     Check that first and then if it fails, then try
 	     parse_timestamp.  */
 
-	  if (strptime (create_time, "%Y-%m-%d", &tm))
+	  if (!isodate_human_to_tm (create_time, &tm))
 	    create_time = tm2ldaptime (&tm);
 	  else if ((t = parse_timestamp (create_time, &end)) != (time_t) -1
 		   && *end == '\0')
 	    {
-	      if (! gmtime_r (&t, &tm))
+
+	      if (!gnupg_gmtime (&t, &tm))
 		create_time = NULL;
 	      else
 		create_time = tm2ldaptime (&tm);
@@ -1795,12 +1796,12 @@ extract_attributes (LDAPMod ***modlist, char *line)
 	     Check that first and then if it fails, then try
 	     parse_timestamp.  */
 
-	  if (strptime (expire_time, "%Y-%m-%d", &tm))
+	  if (!isodate_human_to_tm (expire_time, &tm))
 	    expire_time = tm2ldaptime (&tm);
 	  else if ((t = parse_timestamp (expire_time, &end)) != (time_t) -1
 		   && *end == '\0')
 	    {
-	      if (! gmtime_r (&t, &tm))
+	      if (!gnupg_gmtime (&t, &tm))
 		expire_time = NULL;
 	      else
 		expire_time = tm2ldaptime (&tm);

commit 5d60c7f7e05a06e46e23bafe61cef09ad32aa998
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Apr 10 12:24:43 2015 +0200

    common: Add new function gnupg_gmtime.
    
    * common/gettime.c (gnupg_gmtime): New.
    (gnupg_get_isotime): Use it.  Also take care of an gmtime_t returning
    an error.
    --
    
    The fix in gnupg_get_isotime is only to cover up a theoretical broken
    time (e.g. a value of (time_t)(-2) which is not mapped beyond 2038 on
    32 bit systems).
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/common/gettime.c b/common/gettime.c
index 5a7a745..115f725 100644
--- a/common/gettime.c
+++ b/common/gettime.c
@@ -71,6 +71,29 @@ gnupg_get_time ()
 }
 
 
+/* Wrapper around gmtime_r.
+
+   On systems without gmtime_r this implementation works within gnupg
+   because we use only one thread a time.  FIXME: An independent
+   library may use gmtime in one of its own thread (or via
+   npth_enter/npth_leave) - in this case we run into a problem.  The
+   solution would be to use a mutex here.  */
+struct tm *
+gnupg_gmtime (const time_t *timep, struct tm *result)
+{
+#ifdef HAVE_GMTIME_R
+  return gmtime_r (timep, result);
+#else
+  struct tm *tp;
+
+  tp = gmtime (timep);
+  if (tp)
+    memcpy (result, tp, sizeof *result);
+  return tp;
+#endif
+}
+
+
 /* Return the current time (possibly faked) in ISO format. */
 void
 gnupg_get_isotime (gnupg_isotime_t timebuf)
@@ -82,16 +105,15 @@ gnupg_get_isotime (gnupg_isotime_t timebuf)
   else
     {
       struct tm *tp;
-#ifdef HAVE_GMTIME_R
       struct tm tmbuf;
 
-      tp = gmtime_r (&atime, &tmbuf);
-#else
-      tp = gmtime (&atime);
-#endif
-      snprintf (timebuf, 16, "%04d%02d%02dT%02d%02d%02d",
-                1900 + tp->tm_year, tp->tm_mon+1, tp->tm_mday,
-                tp->tm_hour, tp->tm_min, tp->tm_sec);
+      tp = gnupg_gmtime (&atime, &tmbuf);
+      if (!tp)
+        *timebuf = 0;
+      else
+        snprintf (timebuf, 16, "%04d%02d%02dT%02d%02d%02d",
+                  1900 + tp->tm_year, tp->tm_mon+1, tp->tm_mday,
+                  tp->tm_hour, tp->tm_min, tp->tm_sec);
     }
 }
 
diff --git a/common/gettime.h b/common/gettime.h
index 25886d2..ec68faa 100644
--- a/common/gettime.h
+++ b/common/gettime.h
@@ -29,6 +29,7 @@
 typedef char gnupg_isotime_t[16];
 
 time_t gnupg_get_time (void);
+struct tm *gnupg_gmtime (const time_t *timep, struct tm *result);
 void   gnupg_get_isotime (gnupg_isotime_t timebuf);
 void   gnupg_set_time (time_t newtime, int freeze);
 int    gnupg_faked_time_p (void);

commit f6670100b7a15b2071c2e4062f5c5a678f2a30f6
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Apr 10 12:02:31 2015 +0200

    common: Add new function isodate_human_to_tm
    
    * common/gettime.c (isotime_human_p): Add arg date_only.
    (isodate_human_to_tm): New.
    * common/t-gettime.c (test_isodate_human_to_tm): New.
    (main): Call new test.
    --
    
    This function in intended as replacement for
    
     strptime (foo, "%Y-%m-%d", &bar)
    
    which is not available under Windows.

diff --git a/common/gettime.c b/common/gettime.c
index 80a56bb..5a7a745 100644
--- a/common/gettime.c
+++ b/common/gettime.c
@@ -216,9 +216,11 @@ isotime_p (const char *string)
 /* Scan a string and return true if the string represents the human
    readable format of an ISO time.  This format is:
       yyyy-mm-dd[ hh[:mm[:ss]]]
-   Scanning stops at the second space or at a comma.  */
+   Scanning stops at the second space or at a comma.  If DATE_ONLY is
+   true the time part is not expected and the scanning stops at the
+   first space or at a comma. */
 int
-isotime_human_p (const char *string)
+isotime_human_p (const char *string, int date_only)
 {
   const char *s;
   int i;
@@ -247,6 +249,8 @@ isotime_human_p (const char *string)
     return 1; /* Okay; only date given.  */
   if (!spacep (s))
     return 0;
+  if (date_only)
+    return 1; /* Okay; only date was requested.  */
   s++;
   if (spacep (s))
     return 1; /* Okay, second space stops scanning.  */
@@ -303,7 +307,7 @@ string2isotime (gnupg_isotime_t atime, const char *string)
       atime[15] = 0;
       return 15;
     }
-  if (!isotime_human_p (string))
+  if (!isotime_human_p (string, 0))
     return 0;
   atime[0] = string[0];
   atime[1] = string[1];
@@ -393,6 +397,36 @@ epoch2isotime (gnupg_isotime_t timebuf, time_t atime)
 }
 
 
+/* Parse a short ISO date string (YYYY-MM-DD) into a TM structure.
+   Returns 0 on success.  */
+int
+isodate_human_to_tm (const char *string, struct tm *t)
+{
+  int year, month, day;
+
+  if (!isotime_human_p (string, 1))
+    return -1;
+
+  year  = atoi_4 (string);
+  month = atoi_2 (string + 5);
+  day   = atoi_2 (string + 8);
+
+  /* Basic checks.  */
+  if (year < 1970 || month < 1 || month > 12 || day < 1 || day > 31)
+    return -1;
+
+  memset (t, 0, sizeof *t);
+  t->tm_sec  = 0;
+  t->tm_min  = 0;
+  t->tm_hour = 0;
+  t->tm_mday = day;
+  t->tm_mon  = month-1;
+  t->tm_year = year - 1900;
+  t->tm_isdst = -1;
+  return 0;
+}
+
+
 /* This function is a copy of gpgme/src/conversion.c:_gpgme_timegm.
    If you change it, then update the other one too.  */
 #ifdef HAVE_W32_SYSTEM
diff --git a/common/gettime.h b/common/gettime.h
index 10cae17..25886d2 100644
--- a/common/gettime.h
+++ b/common/gettime.h
@@ -37,10 +37,11 @@ char *elapsed_time_string (time_t since, time_t now);
 
 u32    scan_isodatestr (const char *string);
 int    isotime_p (const char *string);
-int    isotime_human_p (const char *string);
+int    isotime_human_p (const char *string, int date_only);
 size_t string2isotime (gnupg_isotime_t atime, const char *string);
 time_t isotime2epoch (const char *string);
 void   epoch2isotime (gnupg_isotime_t timebuf, time_t atime);
+int    isodate_human_to_tm (const char *string, struct tm *t);
 time_t parse_timestamp (const char *timestamp, char **endp);
 u32    add_days_to_timestamp (u32 stamp, u16 days);
 const char *strtimevalue (u32 stamp);
diff --git a/common/t-gettime.c b/common/t-gettime.c
index 5d554ee..9b3139d 100644
--- a/common/t-gettime.c
+++ b/common/t-gettime.c
@@ -174,6 +174,80 @@ test_string2isotime (void)
 }
 
 
+static void
+test_isodate_human_to_tm (void)
+{
+  struct {
+    const char *string;
+    int okay;
+    int year, mon, mday;
+  } array [] = {
+    { "1970-01-01",      1, 1970,  1,  1 },
+    { "1970-02-01",      1, 1970,  2,  1 },
+    { "1970-12-31",      1, 1970, 12, 31 },
+    { "1971-01-01",      1, 1971,  1,  1 },
+    { "1998-08-15",      1, 1998,  8, 15 },
+    { "2015-04-10",      1, 2015,  4, 10 },
+    { "2015-04-10 11:30",1, 2015,  4, 10 },
+    { "1969-12-31",      0,    0,  0,  0 },
+    { "1900-01-01",      0,    0,  0,  0 },
+    { "",                0,    0,  0,  0 },
+    { "1970-12-32",      0,    0,  0,  0 },
+    { "1970-13-01",      0,    0,  0,  0 },
+    { "1970-01-00",      0,    0,  0,  0 },
+    { "1970-00-01",      0,    0,  0,  0 },
+    { "1970-00-01",      0,    0,  0,  0 },
+    { "1970",            0,    0,  0,  0 },
+    { "1970-01",         0,    0,  0,  0 },
+    { "1970-01-1",       0,    0,  0,  0 },
+    { "1970-1--01",      0,    0,  0,  0 },
+    { "1970-01-01,",     1, 1970,  1,  1 },
+    { "1970-01-01 ",     1, 1970,  1,  1 },
+    { "1970-01-01\t",    1, 1970,  1,  1 },
+    { "1970-01-01;",     0,    0,  0,  0 },
+    { "1970-01-01:",     0,    0,  0,  0 },
+    { "1970_01-01",      0,    0,  0,  0 },
+    { "1970-01_01",      0,    0,  0,  0 },
+    { NULL, 0 }
+  };
+  int idx;
+  int okay;
+  struct tm tmbuf;
+
+  for (idx=0; array[idx].string; idx++)
+    {
+      okay = !isodate_human_to_tm (array[idx].string, &tmbuf);
+      if (okay != array[idx].okay)
+        {
+          fail (idx);
+          if (verbose)
+            fprintf (stderr, "string '%s' expected: %d, got: %d\n",
+                     array[idx].string, (int)array[idx].okay, okay);
+        }
+      else if (!okay)
+        ;
+      else if (tmbuf.tm_year + 1900 != array[idx].year
+               || tmbuf.tm_mon +1   != array[idx].mon
+               || tmbuf.tm_mday     != array[idx].mday)
+        {
+          fail (idx);
+          if (verbose)
+            fprintf (stderr, "string '%s' returned %04d-%02d-%02d\n",
+                     array[idx].string,
+                     tmbuf.tm_year + 1900, tmbuf.tm_mon + 1, tmbuf.tm_mday);
+        }
+      else if (tmbuf.tm_sec || tmbuf.tm_min || tmbuf.tm_hour
+               || tmbuf.tm_isdst != -1)
+        {
+          fail (idx);
+          if (verbose)
+            fprintf (stderr, "string '%s' returned bad time part\n",
+                     array[idx].string);
+        }
+    }
+}
+
+
 int
 main (int argc, char **argv)
 {
@@ -182,6 +256,7 @@ main (int argc, char **argv)
 
   test_isotime2epoch ();
   test_string2isotime ();
+  test_isodate_human_to_tm ();
 
   return !!errcount;
 }

commit 6ad95fe6f1f130c8f6d139a9bd57fc4a0d38292b
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Apr 10 10:59:28 2015 +0200

    dirmngr,w32: Avoid name clash with existing function
    
    * dirmngr/ks-engine-ldap.c (ldap_connect): Rename to my_ldap_connect.

diff --git a/dirmngr/ks-engine-ldap.c b/dirmngr/ks-engine-ldap.c
index 1ce709d..82d6234 100644
--- a/dirmngr/ks-engine-ldap.c
+++ b/dirmngr/ks-engine-ldap.c
@@ -439,8 +439,8 @@ keyspec_to_ldap_filter (const char *keyspec, char **filter, int only_exact)
    OpenPGP Keyserver.  In this case, you also do not need to xfree
    *pgpkeyattrp.  */
 static int
-ldap_connect (parsed_uri_t uri, LDAP **ldap_connp,
-	      char **basednp, char **pgpkeyattrp, int *real_ldapp)
+my_ldap_connect (parsed_uri_t uri, LDAP **ldap_connp,
+                 char **basednp, char **pgpkeyattrp, int *real_ldapp)
 {
   int err = 0;
 
@@ -455,7 +455,7 @@ ldap_connect (parsed_uri_t uri, LDAP **ldap_connp,
   char *pgpkeyattr = "pgpKey";
   int real_ldap = 0;
 
-  log_debug ("ldap_connect(%s:%d/%s????%s%s%s%s%s)\n",
+  log_debug ("my_ldap_connect(%s:%d/%s????%s%s%s%s%s)\n",
 	     uri->host, uri->port,
 	     uri->path ?: "",
 	     uri->auth ? "bindname=" : "", uri->auth ?: "",
@@ -842,7 +842,7 @@ ks_ldap_get (ctrl_t ctrl, parsed_uri_t uri, const char *keyspec,
     return (err);
 
   /* Make sure we are talking to an OpenPGP LDAP server.  */
-  ldap_err = ldap_connect (uri, &ldap_conn, &basedn, &pgpkeyattr, NULL);
+  ldap_err = my_ldap_connect (uri, &ldap_conn, &basedn, &pgpkeyattr, NULL);
   if (ldap_err || !basedn)
     {
       if (ldap_err)
@@ -1021,7 +1021,7 @@ ks_ldap_search (ctrl_t ctrl, parsed_uri_t uri, const char *pattern,
     }
 
   /* Make sure we are talking to an OpenPGP LDAP server.  */
-  ldap_err = ldap_connect (uri, &ldap_conn, &basedn, NULL, NULL);
+  ldap_err = my_ldap_connect (uri, &ldap_conn, &basedn, NULL, NULL);
   if (ldap_err || !basedn)
     {
       if (ldap_err)
@@ -1878,7 +1878,8 @@ ks_ldap_put (ctrl_t ctrl, parsed_uri_t uri,
   /* Elide a warning.  */
   (void) ctrl;
 
-  ldap_err = ldap_connect (uri, &ldap_conn, &basedn, &pgpkeyattr, &real_ldap);
+  ldap_err = my_ldap_connect (uri,
+                              &ldap_conn, &basedn, &pgpkeyattr, &real_ldap);
   if (ldap_err || !basedn)
     {
       if (ldap_err)

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

Summary of changes:
 agent/Makefile.am        |  2 +-
 common/Makefile.am       |  2 +-
 common/gettime.c         | 78 +++++++++++++++++++++++++++++++++++++++++-------
 common/gettime.h         |  4 ++-
 common/t-gettime.c       | 75 ++++++++++++++++++++++++++++++++++++++++++++++
 dirmngr/Makefile.am      |  2 +-
 dirmngr/ks-engine-ldap.c | 22 +++++++-------
 g10/Makefile.am          |  3 +-
 g13/Makefile.am          |  2 +-
 kbx/Makefile.am          |  3 +-
 scd/Makefile.am          |  2 +-
 sm/Makefile.am           |  2 +-
 tools/Makefile.am        |  2 +-
 13 files changed, 166 insertions(+), 33 deletions(-)


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




More information about the Gnupg-commits mailing list