summaryrefslogtreecommitdiffstats
path: root/common/util.h
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2008-06-05 09:46:12 +0200
committerWerner Koch <wk@gnupg.org>2008-06-05 09:46:12 +0200
commitb11af4cf50ff2f8de1fda9a77ebb4ccf5cc926c0 (patch)
treefe1ea0381e7b94e4b69e7322bf143569486cb61b /common/util.h
parentChanges the header presented before requesting the user ID. (diff)
downloadgnupg2-b11af4cf50ff2f8de1fda9a77ebb4ccf5cc926c0.tar.xz
gnupg2-b11af4cf50ff2f8de1fda9a77ebb4ccf5cc926c0.zip
As a failsafe measure use memcpy instead of strcpy in gnupg_copy_time.
Typo fix.
Diffstat (limited to 'common/util.h')
-rw-r--r--common/util.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/common/util.h b/common/util.h
index 269aed193..7703be2b6 100644
--- a/common/util.h
+++ b/common/util.h
@@ -115,13 +115,19 @@ gpg_error_t add_days_to_isotime (gnupg_isotime_t atime, int ndays);
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;
}