[Pkg-gnupg-commit] [gnupg2] 98/160: gpg: Make sure a user ID packet has always a terminating Nul in memory.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Fri Jul 15 09:36:40 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch upstream
in repository gnupg2.

commit d8bce478be3ae9e401841a77d189ef3c81ccb757
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Jul 1 15:18:59 2016 +0200

    gpg: Make sure a user ID packet has always a terminating Nul in memory.
    
    * g10/keygen.c (write_uid): Avoid overflow.
    --
    
    Also the actual length if the user ID is given by LEN, using NAME
    diretcly is often more convenient.
---
 g10/keygen.c | 2 +-
 g10/packet.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/g10/keygen.c b/g10/keygen.c
index 3a9a8e7..2b3d328 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -202,7 +202,7 @@ write_uid( KBNODE root, const char *s )
     size_t n = strlen(s);
 
     pkt->pkttype = PKT_USER_ID;
-    pkt->pkt.user_id = xmalloc_clear( sizeof *pkt->pkt.user_id + n - 1 );
+    pkt->pkt.user_id = xmalloc_clear (sizeof *pkt->pkt.user_id + n);
     pkt->pkt.user_id->len = n;
     pkt->pkt.user_id->ref = 1;
     strcpy(pkt->pkt.user_id->name, s);
diff --git a/g10/packet.h b/g10/packet.h
index 0ff28c8..a496c4b 100644
--- a/g10/packet.h
+++ b/g10/packet.h
@@ -293,7 +293,7 @@ typedef struct
   } flags;
   /* The text contained in the user id packet, which is normally the
      name and email address of the key holder (See RFC 4880 5.11).
-     (Serialized.)  */
+     (Serialized.). For convenience an extra Nul is always appended.  */
   char name[1];
 } PKT_user_id;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list