summaryrefslogtreecommitdiff
path: root/libextra
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2006-10-30 12:33:23 +0000
committerSimon Josefsson <simon@josefsson.org>2006-10-30 12:33:23 +0000
commitec4c83502a8d7ffb4b1f54b28db6f38bb01fedfc (patch)
tree9ef3be37a90125528bde18bb33279166ee802e30 /libextra
parent0895510f7055de786341b244ccd5b583f7604ed9 (diff)
downloadgnutls-ec4c83502a8d7ffb4b1f54b28db6f38bb01fedfc.tar.gz
(gnutls_openpgp_key_get_name): Make SIZEOF_BUF contain actual/required
buffer size on return. Suggested by ludovic.courtes@laas.fr (Ludovic Courtès).
Diffstat (limited to 'libextra')
-rw-r--r--libextra/openpgp/pgp.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libextra/openpgp/pgp.c b/libextra/openpgp/pgp.c
index 0821a5ef88..c1aac52d5c 100644
--- a/libextra/openpgp/pgp.c
+++ b/libextra/openpgp/pgp.c
@@ -279,7 +279,8 @@ _gnutls_openpgp_count_key_names (gnutls_openpgp_key_t key)
* @key: the structure that contains the OpenPGP public key.
* @idx: the index of the ID to extract
* @buf: a pointer to a structure to hold the name
- * @sizeof_buf: holds the size of 'buf'
+ * @sizeof_buf: holds the maximum size of @buf, on return hold the
+ * actual/required size of @buf.
*
* Extracts the userID from the parsed OpenPGP key.
*
@@ -338,10 +339,9 @@ gnutls_openpgp_key_get_name (gnutls_openpgp_key_t key,
goto leave;
}
- size = uid->len < *sizeof_buf ? uid->len : *sizeof_buf - 1;
- memcpy (buf, uid->name, size);
-
- buf[size] = '\0'; /* make sure it's a string */
+ memcpy (buf, uid->name, uid->len);
+ buf[uid->len] = '\0'; /* make sure it's a string */
+ *sizeof_buf = uid->len + 1;
if (uid->is_revoked)
{