aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal H. Walfield <[email protected]>2016-02-07 23:31:35 +0000
committerNeal H. Walfield <[email protected]>2016-02-07 23:31:54 +0000
commite8d2d53053fa6f263e517b2816ea9f22af3a6682 (patch)
tree591469ce4f1949c4f660c623ed74d5298a26827e
parentcommon: Fix comment. (diff)
downloadgnupg-e8d2d53053fa6f263e517b2816ea9f22af3a6682.tar.gz
gnupg-e8d2d53053fa6f263e517b2816ea9f22af3a6682.zip
gpg: Fix format_keyid when dynamically allocating the buffer.
* g10/keyid.c (format_keyid): Return a char *, not a const char *. If BUFFER is NULL, then set LEN to the static buffer's size. -- Signed-off-by: Neal H. Walfield <[email protected]>
-rw-r--r--g10/keydb.h2
-rw-r--r--g10/keyid.c7
2 files changed, 6 insertions, 3 deletions
diff --git a/g10/keydb.h b/g10/keydb.h
index e679d94b4..9b4a1cfb5 100644
--- a/g10/keydb.h
+++ b/g10/keydb.h
@@ -399,7 +399,7 @@ char *pubkey_string (PKT_public_key *pk, char *buffer, size_t bufsize);
#define PUBKEY_STRING_SIZE 32
u32 v3_keyid (gcry_mpi_t a, u32 *ki);
void hash_public_key( gcry_md_hd_t md, PKT_public_key *pk );
-const char *format_keyid (u32 *keyid, int format, char *buffer, int len);
+char *format_keyid (u32 *keyid, int format, char *buffer, int len);
size_t keystrlen(void);
const char *keystr(u32 *keyid);
const char *keystr_with_sub (u32 *main_kid, u32 *sub_kid);
diff --git a/g10/keyid.c b/g10/keyid.c
index f6842762e..49eb5f6d5 100644
--- a/g10/keyid.c
+++ b/g10/keyid.c
@@ -274,12 +274,15 @@ v3_keyid (gcry_mpi_t a, u32 *ki)
}
-const char *
+char *
format_keyid (u32 *keyid, int format, char *buffer, int len)
{
char tmp[KEYID_STR_SIZE];
if (! buffer)
- buffer = tmp;
+ {
+ buffer = tmp;
+ len = sizeof (tmp);
+ }
if (format == KF_DEFAULT)
format = opt.keyid_format;