[svn] GnuPG - r4776 - trunk/common

svn author wk cvs at cvs.gnupg.org
Thu Jun 5 09:46:13 CEST 2008


Author: wk
Date: 2008-06-05 09:46:12 +0200 (Thu, 05 Jun 2008)
New Revision: 4776

Modified:
   trunk/common/ChangeLog
   trunk/common/gettime.c
   trunk/common/util.h
Log:
As a failsafe measure use memcpy instead of strcpy in gnupg_copy_time.
Typo fix.


Modified: trunk/common/ChangeLog
===================================================================
--- trunk/common/ChangeLog	2008-06-01 19:44:05 UTC (rev 4775)
+++ trunk/common/ChangeLog	2008-06-05 07:46:12 UTC (rev 4776)
@@ -1,3 +1,7 @@
+2008-06-05  Werner Koch  <wk at g10code.com>
+
+	* util.h (gnupg_copy_time): Replace strcpy by memcpy.
+
 2008-05-26  Werner Koch  <wk at g10code.com>
 
 	* asshelp.c (send_one_option, send_pinentry_environment): use

Modified: trunk/common/gettime.c
===================================================================
--- trunk/common/gettime.c	2008-06-01 19:44:05 UTC (rev 4775)
+++ trunk/common/gettime.c	2008-06-05 07:46:12 UTC (rev 4776)
@@ -402,7 +402,7 @@
 
 
 /* Convert YEAR, MONTH and DAY into the Julian date.  We assume that
-   it is already noon; we dont; support dates before 1582-10-15. */
+   it is already noon.  We do not support dates before 1582-10-15. */
 static unsigned long
 date2jd (int year, int month, int day)
 {

Modified: trunk/common/util.h
===================================================================
--- trunk/common/util.h	2008-06-01 19:44:05 UTC (rev 4775)
+++ trunk/common/util.h	2008-06-05 07:46:12 UTC (rev 4776)
@@ -115,13 +115,19 @@
 gpg_error_t check_isotime (const gnupg_isotime_t atime);
 
 /* Copy one ISO date to another, this is inline so that we can do a
-   sanity check. */
+   minimal sanity check.  A null date (empty string) is allowed.  */
 static inline void
 gnupg_copy_time (gnupg_isotime_t d, const gnupg_isotime_t s)
 {
-  if (*s && (strlen (s) != 15 || s[8] != 'T'))
-    BUG();
-  strcpy (d, s);
+  if (*s)
+    {
+      if ((strlen (s) != 15 || s[8] != 'T'))
+        BUG();
+      memcpy (d, s, 15);
+      d[15] = 0;
+    }
+  else
+    *d = 0;
 }
 
 




More information about the Gnupg-commits mailing list