[git] GnuPG - branch, STABLE-BRANCH-2-0, updated. gnupg-2.0.16-19-g18936a1
by Werner Koch
cvs at cvs.gnupg.org
Mon Jan 10 19:54:23 CET 2011
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".
The branch, STABLE-BRANCH-2-0 has been updated
via 18936a1970aeafd64cbf7b04d8622b331b872818 (commit)
from 344d72b2f7caaa217941adc8cdb70e722ed8f888 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 18936a1970aeafd64cbf7b04d8622b331b872818
Author: Werner Koch <wk at gnupg.org>
Date: Mon Jan 10 19:35:10 2011 +0100
Fix bug#1307.
diff --git a/common/ChangeLog b/common/ChangeLog
index 9c18680..84843cd 100644
--- a/common/ChangeLog
+++ b/common/ChangeLog
@@ -1,3 +1,9 @@
+2011-01-10 Thomas Mraz <t8m at centrum.cz> (wk)
+
+ * pka.c (get_pka_info) [!USE_ADNS]: Turn ANSWER into a union to
+ avoid aliasing problems with modern compilers. See bug#1307.
+ Reported by Steve Grubb.
+
2011-01-10 Werner Koch <wk at g10code.com>
* session-env.c (update_var): Fix same value test. Fixes
diff --git a/common/pka.c b/common/pka.c
index 3d68802..b1247f6 100644
--- a/common/pka.c
+++ b/common/pka.c
@@ -173,7 +173,11 @@ get_pka_info (const char *address, unsigned char *fpr)
return buffer;
#else /*!USE_ADNS*/
- unsigned char answer[PACKETSZ];
+ union
+ {
+ signed char p[PACKETSZ];
+ HEADER h;
+ } answer;
int anslen;
int qdcount, ancount, nscount, arcount;
int rc;
@@ -192,11 +196,11 @@ get_pka_info (const char *address, unsigned char *fpr)
memcpy (name, address, domain - address);
strcpy (stpcpy (name + (domain-address), "._pka."), domain+1);
- anslen = res_query (name, C_IN, T_TXT, answer, PACKETSZ);
+ anslen = res_query (name, C_IN, T_TXT, answer.p, PACKETSZ);
xfree (name);
if (anslen < sizeof(HEADER))
return NULL; /* DNS resolver returned a too short answer. */
- if ( (rc=((HEADER*)answer)->rcode) != NOERROR )
+ if ( (rc=answer.h.rcode) != NOERROR )
return NULL; /* DNS resolver returned an error. */
/* We assume that PACKETSZ is large enough and don't do dynmically
@@ -204,16 +208,16 @@ get_pka_info (const char *address, unsigned char *fpr)
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 (answer.h.qdcount);
+ ancount = ntohs (answer.h.ancount);
+ nscount = ntohs (answer.h.nscount);
+ arcount = ntohs (answer.h.arcount);
if (!ancount)
return NULL; /* Got no answer. */
- p = answer + sizeof (HEADER);
- pend = answer + anslen; /* Actually points directly behind the buffer. */
+ p = answer.p + sizeof (HEADER);
+ pend = answer.p + anslen; /* Actually points directly behind the buffer. */
while (qdcount-- && p < pend)
{
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 7e09fb7..92bfde6 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,14 @@
+2011-01-10 Werner Koch <wk at g10code.com>
+
+ * keygen.c (ask_user_id): Fix duplicate test for AMAIL by correct
+ ANAME. See bug#1307. Reported by Steve Grubb.
+
+ * import.c (import_keys_internal): Make loop code a bit more
+ readable. See bug#1307. Reported by Steve Grubb.
+
+ * sign.c (sign_file): Fix TEMP_HASHLEN computation. See bug#1307.
+ Reported by Steve Grubb.
+
2010-10-29 David Shaw <dshaw at jabberwocky.com>
* pkclist.c (select_algo_from_prefs): Make sure the scores can't
diff --git a/g10/import.c b/g10/import.c
index e2d77b0..ba2439d 100644
--- a/g10/import.c
+++ b/g10/import.c
@@ -175,10 +175,9 @@ import_keys_internal( IOBUF inp, char **fnames, int nnames,
rc = import( inp, "[stream]", stats, fpr, fpr_len, options);
}
else {
- if( !fnames && !nnames )
- nnames = 1; /* Ohh what a ugly hack to jump into the loop */
+ int once = (!fnames && !nnames);
- for(i=0; i < nnames; i++ ) {
+ for(i=0; once || i < nnames; once=0, i++ ) {
const char *fname = fnames? fnames[i] : NULL;
IOBUF inp2 = iobuf_open(fname);
if( !fname )
@@ -201,8 +200,6 @@ import_keys_internal( IOBUF inp, char **fnames, int nnames,
log_error("import from `%s' failed: %s\n", fname,
g10_errstr(rc) );
}
- if( !fname )
- break;
}
}
if (!stats_handle) {
diff --git a/g10/keygen.c b/g10/keygen.c
index 3aaae9c..8c3e9f6 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -2247,7 +2247,7 @@ ask_user_id (int mode, KBNODE keyblock)
xfree(answer);
}
xfree(answer);
- if( !amail && !acomment && !amail )
+ if( !aname && !acomment && !amail )
break;
xfree(uid); uid = NULL;
}
diff --git a/g10/sign.c b/g10/sign.c
index f54e0d9..94e107c 100644
--- a/g10/sign.c
+++ b/g10/sign.c
@@ -867,8 +867,8 @@ sign_file( strlist_t filenames, int detached, strlist_t locusr,
{
if (sk_rover->sk->pubkey_algo == PUBKEY_ALGO_DSA)
{
- int temp_hashlen = gcry_mpi_get_nbits
- (sk_rover->sk->skey[1])+7/8;
+ int temp_hashlen = (gcry_mpi_get_nbits
+ (sk_rover->sk->skey[1])+7)/8;
/* Pick a hash that is large enough for our
largest q */
-----------------------------------------------------------------------
Summary of changes:
common/ChangeLog | 6 ++++++
common/pka.c | 22 +++++++++++++---------
g10/ChangeLog | 11 +++++++++++
g10/import.c | 7 ++-----
g10/keygen.c | 2 +-
g10/sign.c | 4 ++--
6 files changed, 35 insertions(+), 17 deletions(-)
hooks/post-receive
--
The GNU Privacy Guard
http://git.gnupg.org
More information about the Gnupg-commits
mailing list