[Pkg-gnupg-commit] [gnupg2] 98/292: agent: Fix get_socket_name.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Mon Nov 21 06:31:30 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gnupg2.
commit fb3b3e1e7a4219f61a834fd07809898918611c2f
Author: NIIBE Yutaka <gniibe at fsij.org>
Date: Fri Oct 7 19:00:10 2016 +0900
agent: Fix get_socket_name.
* agent/gpg-agent.c (get_socket_name): Fix the size of copying.
--
Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>
---
agent/gpg-agent.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index 70d9775..32e072b 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
@@ -599,19 +599,21 @@ get_socket_name (int fd)
log_error ("socket name not present for file descriptor %d\n", fd);
else if (len > sizeof(un))
log_error ("socket name for file descriptor %d was truncated "
- "(passed %lu bytes, wanted %u)\n", fd, sizeof(un), len);
+ "(passed %zu bytes, wanted %u)\n", fd, sizeof(un), len);
else
{
- log_debug ("file descriptor %d has path %s (%lu octets)\n", fd,
- un.sun_path, len - offsetof (struct sockaddr_un, sun_path));
- name = xtrymalloc (len - offsetof (struct sockaddr_un, sun_path) + 1);
+ size_t namelen = len - offsetof (struct sockaddr_un, sun_path);
+
+ log_debug ("file descriptor %d has path %s (%zu octets)\n", fd,
+ un.sun_path, namelen);
+ name = xtrymalloc (namelen + 1);
if (!name)
log_error ("failed to allocate memory for name of fd %d: %s\n",
fd, gpg_strerror (gpg_error_from_syserror ()));
else
{
- memcpy (name, un.sun_path, len);
- name[len] = 0;
+ memcpy (name, un.sun_path, namelen);
+ name[namelen] = 0;
}
}
--
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