From 78bd20d676da382b9daaf2e26b0d9b0bef4df12d Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Wed, 23 Jun 2004 21:15:21 +0000 Subject: [PATCH] 2004-06-23 Marcus Brinkmann * key.c (_gpgme_key_append_name): Make sure tail points to the byte following the uid. (_gpgme_key_add_sig): Likewise. Don't use calloc, but malloc and memset. --- gpgme/ChangeLog | 7 +++++++ gpgme/key.c | 8 +++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index c617801..34d2939 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,3 +1,10 @@ +2004-06-23 Marcus Brinkmann + + * key.c (_gpgme_key_append_name): Make sure tail points to the + byte following the uid. + (_gpgme_key_add_sig): Likewise. Don't use calloc, but malloc and + memset. + 2004-06-02 Marcus Brinkmann * libgpgme.vers: Remove C-style comment, which is not supported by diff --git a/gpgme/key.c b/gpgme/key.c index 4634c26..444f067 100644 --- a/gpgme/key.c +++ b/gpgme/key.c @@ -220,7 +220,7 @@ _gpgme_key_append_name (gpgme_key_t key, char *src) dst = uid->uid; _gpgme_decode_c_string (src, &dst, src_len + 1); - dst += src_len + 1; + dst += strlen (dst) + 1; if (key->protocol == GPGME_PROTOCOL_CMS) parse_x509_user_id (uid->uid, &uid->name, &uid->email, &uid->comment, dst); @@ -253,9 +253,11 @@ _gpgme_key_add_sig (gpgme_key_t key, char *src) /* We can malloc a buffer of the same length, because the converted string will never be larger. Actually we allocate it twice the size, so that we are able to store the parsed stuff there too. */ - sig = calloc (1, sizeof (*sig) + 2 * src_len + 3); + sig = malloc (sizeof (*sig) + 2 * src_len + 3); if (!sig) return NULL; + memset (sig, 0, sizeof *sig); + sig->keyid = sig->_keyid; sig->_keyid[16] = '\0'; sig->uid = ((char *) sig) + sizeof (*sig); @@ -264,7 +266,7 @@ _gpgme_key_add_sig (gpgme_key_t key, char *src) { char *dst = sig->uid; _gpgme_decode_c_string (src, &dst, src_len + 1); - dst += src_len + 1; + dst += strlen (dst) + 1; if (key->protocol == GPGME_PROTOCOL_CMS) parse_x509_user_id (sig->uid, &sig->name, &sig->email, &sig->comment, dst); -- 2.26.2