diff options
author | NIIBE Yutaka <[email protected]> | 2017-04-10 06:04:57 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2017-04-10 06:04:57 +0000 |
commit | 170660ed11b56145dea4865e751ae5aff1681fe2 (patch) | |
tree | cc783826a3fc71cec59e67ee071be6a9e441387d | |
parent | scd: Relax a condition for p15 driver. (diff) | |
download | gnupg-170660ed11b56145dea4865e751ae5aff1681fe2.tar.gz gnupg-170660ed11b56145dea4865e751ae5aff1681fe2.zip |
agent: Use "ll" length specifier when time_t is larger.
* agent/command.c (cmd_keytocard): Use KEYTOCARD_TIMESTAMP_FORMAT.
--
On a big-endian 32-bit platform which uses 64-bit time_t, it might go
wrong.
Signed-off-by: NIIBE Yutaka <[email protected]>
-rw-r--r-- | agent/command.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/agent/command.c b/agent/command.c index 1f8f7c2d8..ab6d7eb24 100644 --- a/agent/command.c +++ b/agent/command.c @@ -2477,6 +2477,12 @@ cmd_delete_key (assuan_context_t ctx, char *line) +#if SIZEOF_TIME_T > SIZEOF_UNSIGNED_LONG +#define KEYTOCARD_TIMESTAMP_FORMAT "(10:created-at10:%010llu))" +#else +#define KEYTOCARD_TIMESTAMP_FORMAT "(10:created-at10:%010lu))" +#endif + static const char hlp_keytocard[] = "KEYTOCARD [--force] <hexstring_with_keygrip> <serialno> <id> <timestamp>\n" "\n"; @@ -2580,7 +2586,7 @@ cmd_keytocard (assuan_context_t ctx, char *line) gcry_sexp_release (s_skey); keydatalen--; /* Decrement for last '\0'. */ /* Add timestamp "created-at" in the private key */ - snprintf (keydata+keydatalen-1, 30, "(10:created-at10:%010lu))", timestamp); + snprintf (keydata+keydatalen-1, 30, KEYTOCARD_TIMESTAMP_FORMAT, timestamp); keydatalen += 10 + 19 - 1; err = divert_writekey (ctrl, force, serialno, id, keydata, keydatalen); xfree (keydata); |