~ubuntu-branches/ubuntu/oneiric/gnupg2/oneiric-proposed

« back to all changes in this revision

Viewing changes to common/pka.c

  • Committer: Bazaar Package Importer
  • Author(s): Marc Deslauriers
  • Date: 2011-05-25 14:27:35 UTC
  • mfrom: (1.1.15 upstream) (7.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110525142735-jccyw0fopnyv728q
Tags: 2.0.17-2ubuntu1
* Merge from debian unstable. Remaining changes:
  - Add udev rules to give gpg access to some smartcard readers;
    Debian #543217.
    . debian/gnupg2.dev: udev rules to set ACLs on SCM smartcard readers.
    . debian/rules: Call dh_installudev.
  - debian/control: Rename Vcs-* to XS-Debian-Vcs-*.

Show diffs side-by-side

added added

removed removed

Lines of Context:
173
173
  return buffer;
174
174
 
175
175
#else /*!USE_ADNS*/
176
 
  unsigned char answer[PACKETSZ];
 
176
  union
 
177
    {
 
178
      signed char p[PACKETSZ];
 
179
      HEADER h;
 
180
    } answer;
177
181
  int anslen;
178
182
  int qdcount, ancount, nscount, arcount;
179
183
  int rc;
192
196
  memcpy (name, address, domain - address);
193
197
  strcpy (stpcpy (name + (domain-address), "._pka."), domain+1);
194
198
 
195
 
  anslen = res_query (name, C_IN, T_TXT, answer, PACKETSZ);
 
199
  anslen = res_query (name, C_IN, T_TXT, answer.p, PACKETSZ);
196
200
  xfree (name);
197
201
  if (anslen < sizeof(HEADER))
198
202
    return NULL; /* DNS resolver returned a too short answer. */
199
 
  if ( (rc=((HEADER*)answer)->rcode) != NOERROR )
 
203
  if ( (rc=answer.h.rcode) != NOERROR )
200
204
    return NULL; /* DNS resolver returned an error. */
201
205
 
202
206
  /* We assume that PACKETSZ is large enough and don't do dynmically
204
208
  if (anslen > PACKETSZ)
205
209
    return NULL; /* DNS resolver returned a too long answer */
206
210
 
207
 
  qdcount = ntohs (((HEADER*)answer)->qdcount);
208
 
  ancount = ntohs (((HEADER*)answer)->ancount);
209
 
  nscount = ntohs (((HEADER*)answer)->nscount);
210
 
  arcount = ntohs (((HEADER*)answer)->arcount);
 
211
  qdcount = ntohs (answer.h.qdcount);
 
212
  ancount = ntohs (answer.h.ancount);
 
213
  nscount = ntohs (answer.h.nscount);
 
214
  arcount = ntohs (answer.h.arcount);
211
215
 
212
216
  if (!ancount)
213
217
    return NULL; /* Got no answer. */
214
218
 
215
 
  p = answer + sizeof (HEADER);
216
 
  pend = answer + anslen; /* Actually points directly behind the buffer. */
 
219
  p = answer.p + sizeof (HEADER);
 
220
  pend = answer.p + anslen; /* Actually points directly behind the buffer. */
217
221
 
218
222
  while (qdcount-- && p < pend)
219
223
    {