[Pkg-gnupg-commit] [gnupg2] 30/205: dirmngr: fix for memory alignment.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Wed May 11 08:38:11 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch experimental
in repository gnupg2.
commit 6fbe12a51e8fe2649ffe5a8a02aa93026a8f02cd
Author: NIIBE Yutaka <gniibe at fsij.org>
Date: Mon Feb 15 10:55:34 2016 +0900
dirmngr: fix for memory alignment.
* dirmngr/dns-stuff.c (get_dns_cert): Cast through void *.
(getsrv, get_dns_cname): Make sure it's aligned for HEADER.
--
Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>
---
dirmngr/dns-stuff.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/dirmngr/dns-stuff.c b/dirmngr/dns-stuff.c
index 40c71f3..191719e 100644
--- a/dirmngr/dns-stuff.c
+++ b/dirmngr/dns-stuff.c
@@ -821,8 +821,8 @@ get_dns_cert (const char *name, int want_certtype,
answer, 65536);
/* Not too big, not too small, no errors and at least 1 answer. */
if (r >= sizeof (HEADER) && r <= 65536
- && (((HEADER *) answer)->rcode) == NOERROR
- && (count = ntohs (((HEADER *) answer)->ancount)))
+ && (((HEADER *)(void *) answer)->rcode) == NOERROR
+ && (count = ntohs (((HEADER *)(void *) answer)->ancount)))
{
int rc;
unsigned char *pt, *emsg;
@@ -1081,8 +1081,12 @@ getsrv (const char *name,struct srventry **list)
}
#else /*!USE_ADNS*/
{
- unsigned char answer[2048];
- HEADER *header = (HEADER *)answer;
+ union {
+ unsigned char ans[2048];
+ HEADER header[1];
+ } res;
+ unsigned char *answer = res.ans;
+ HEADER *header = res.header;
unsigned char *pt, *emsg;
int r;
u16 dlen;
@@ -1305,8 +1309,12 @@ get_dns_cname (const char *name, char **r_cname)
}
#else /*!USE_ADNS*/
{
- unsigned char answer[2048];
- HEADER *header = (HEADER *)answer;
+ union {
+ unsigned char ans[2048];
+ HEADER header[1];
+ } res;
+ unsigned char *answer = res.ans;
+ HEADER *header = res.header;
unsigned char *pt, *emsg;
int r;
char *cname;
--
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