aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2003-10-31 12:07:48 +0000
committerWerner Koch <[email protected]>2003-10-31 12:07:48 +0000
commit2f1226cea902076ef98396db58983298ed079d51 (patch)
tree75e9dd3e1dc2044a7570dfa8ab42e45c0c4bafd6
parent2003-10-10 Marcus Brinkmann <[email protected]> (diff)
downloadgpgme-2f1226cea902076ef98396db58983298ed079d51.tar.gz
gpgme-2f1226cea902076ef98396db58983298ed079d51.zip
(parse_timestamp): Detect ISO 8601 timestamps and try
to convert them.
-rw-r--r--TODO9
-rw-r--r--gpgme/ChangeLog5
-rw-r--r--gpgme/keylist.c40
-rw-r--r--gpgme/verify.c2
4 files changed, 53 insertions, 3 deletions
diff --git a/TODO b/TODO
index 80f4b856..e5841a85 100644
--- a/TODO
+++ b/TODO
@@ -26,12 +26,13 @@ Hey Emacs, this is -*- outline -*- mode!
* Thread support:
** When GNU Pth supports sendmsg/recvmsg, wrap them properly.
+** Without timegm (3) support our ISO time parser is not thread safe.
* New features:
** notification system
We need a simple notification system, probably a simple callback
with a string and some optional arguments. This is for example
- required to notify an application of a changed smartcard, The
+ required to notify an application of a changed smartcard, The
application can then do whatever is required. There are other
usages too. This notfication system should be independent of any
contextes of course.
@@ -56,7 +57,11 @@ Hey Emacs, this is -*- outline -*- mode!
worked around in a different way
*** Selecting the symmetric cipher.
*** Exchanging keys with key servers.
-
+** Allow selection of subkeys
+** Allow to return time stamps in ISO format
+ This allows us to handle years later than 2037 properly. With the
+ time_t interface they are all mapped to 2037-12-31
+
* Documentation
** Document validity and trust issues.
diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog
index 3e366921..2966d6be 100644
--- a/gpgme/ChangeLog
+++ b/gpgme/ChangeLog
@@ -1,3 +1,8 @@
+2003-10-31 Werner Koch <[email protected]>
+
+ * keylist.c (parse_timestamp): Detect ISO 8601 timestamps and try
+ to convert them.
+
2003-10-10 Marcus Brinkmann <[email protected]>
* genkey.c (get_key_parameter): Make a copy of the key parameters.
diff --git a/gpgme/keylist.c b/gpgme/keylist.c
index 07c9385c..9bb5e47c 100644
--- a/gpgme/keylist.c
+++ b/gpgme/keylist.c
@@ -122,7 +122,45 @@ parse_timestamp (char *timestamp)
if (!*timestamp)
return 0;
- return (time_t) strtoul (timestamp, NULL, 10);
+ if (strlen (timestamp) >= 15 && timestamp[8] == 'T')
+ {
+ struct tm buf;
+ int year;
+
+ year = atoi_4 (timestamp);
+ if (year < 1900)
+ return (time_t)(-1);
+
+ /* Fixme: We would better use a configure test to see whether
+ mktime can handle dates beyond 2038. */
+ if (sizeof (time_t) <= 4 && year >= 2038)
+ return (time_t)2145914603; /* 2037-12-31 23:23:23 */
+
+ memset (&buf, 0, sizeof buf);
+ buf.tm_year = year - 1900;
+ buf.tm_mon = atoi_2 (timestamp+4) - 1;
+ buf.tm_mday = atoi_2 (timestamp+6);
+ buf.tm_hour = atoi_2 (timestamp+9);
+ buf.tm_min = atoi_2 (timestamp+11);
+ buf.tm_sec = atoi_2 (timestamp+13);
+
+#ifdef HAVE_TIMEGM
+ return timegm (&buf);
+#else
+ {
+ time_t tim;
+
+ putenv ("TZ=UTC");
+ tim = mktime (&buf);
+#ifdef __GNUC__
+#warning fixme: we must somehow reset TZ here. It is not threadsafe anyway.
+#endif
+ return tim;
+ }
+#endif /* !HAVE_TIMEGM */
+ }
+ else
+ return (time_t) strtoul (timestamp, NULL, 10);
}
diff --git a/gpgme/verify.c b/gpgme/verify.c
index 3f70851c..b92e753d 100644
--- a/gpgme/verify.c
+++ b/gpgme/verify.c
@@ -259,6 +259,8 @@ parse_valid_sig (gpgme_signature_t sig, char *args)
{
char *tail;
errno = 0;
+
+ /* FIXME: We need to cope with ISO time strings here. */
sig->timestamp = strtol (end, &tail, 0);
if (errno || end == tail || (*tail && *tail != ' '))
return gpg_error (GPG_ERR_INV_ENGINE);