diff options
author | Marcus Brinkmann <mb@g10code.com> | 2010-04-20 03:11:35 +0200 |
---|---|---|
committer | Marcus Brinkmann <mb@g10code.com> | 2010-04-20 03:11:35 +0200 |
commit | 0e960d940a3b52406bb72af2750b6b6d29e39067 (patch) | |
tree | f1836dba3a919ea6bd59a94fa6397f461ef222be /common/pka.c | |
parent | Fixed dependencies and a syntax error (diff) | |
download | gnupg2-0e960d940a3b52406bb72af2750b6b6d29e39067.tar.xz gnupg2-0e960d940a3b52406bb72af2750b6b6d29e39067.zip |
common/
2010-04-20 Marcus Brinkmann <marcus@g10code.de>
* logging.c (do_log_ignore_arg): New helper function.
(log_string): Use it to remove ugly volatile hack that causes gcc
warning.
(log_flush): Likewise.
* sysutils.c (gnupg_unsetenv) [!HAVE_W32CE_SYSTEM]: Return something.
(gnupg_setenv) [!HAVE_W32CE_SYSTEM]: Likewise.
* pka.c (get_pka_info): Solve strict aliasing rule violation.
* t-exechelp.c (test_close_all_fds): Use dummy variables to
silence gcc warning.
kbx/
2010-04-20 Marcus Brinkmann <marcus@g10code.de>
* keybox-update.c [!HAVE_DOSISH_SYSTEM]: Include
../common/sysutils.h even then to silence gcc warning about
missing declaration of gnupg_remove.
tools/
2010-04-20 Marcus Brinkmann <marcus@g10code.de>
* gpgconf-comp.c (option_check_validity): Use dummy variables to
silence gcc warning.
Diffstat (limited to 'common/pka.c')
-rw-r--r-- | common/pka.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/common/pka.c b/common/pka.c index 751ccf7c2..5cdc323e6 100644 --- a/common/pka.c +++ b/common/pka.c @@ -180,7 +180,7 @@ get_pka_info (const char *address, unsigned char *fpr) unsigned char *p, *pend; const char *domain; char *name; - + HEADER header; domain = strrchr (address, '@'); if (!domain || domain == address || !domain[1]) @@ -196,18 +196,24 @@ get_pka_info (const char *address, unsigned char *fpr) xfree (name); if (anslen < sizeof(HEADER)) return NULL; /* DNS resolver returned a too short answer. */ - if ( (rc=((HEADER*)answer)->rcode) != NOERROR ) + + /* Don't despair: A good compiler should optimize this away, as + header is just 32 byte and constant at compile time. It's + one way to comply with strict aliasing rules. */ + memcpy (&header, answer, sizeof (header)); + + if ( (rc=header.rcode) != NOERROR ) return NULL; /* DNS resolver returned an error. */ /* We assume that PACKETSZ is large enough and don't do dynmically expansion of the buffer. */ if (anslen > PACKETSZ) return NULL; /* DNS resolver returned a too long answer */ - - qdcount = ntohs (((HEADER*)answer)->qdcount); - ancount = ntohs (((HEADER*)answer)->ancount); - nscount = ntohs (((HEADER*)answer)->nscount); - arcount = ntohs (((HEADER*)answer)->arcount); + + qdcount = ntohs (header.qdcount); + ancount = ntohs (header.ancount); + nscount = ntohs (header.nscount); + arcount = ntohs (header.arcount); if (!ancount) return NULL; /* Got no answer. */ |