1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-21 01:02:46 +02:00

dirmngr: Change DNS code to make additions easier.

* dirmngr/dns-cert.c (get_dns_cert) [!USE_ADNS]: Change loop to allow
adding more resource types.
This commit is contained in:
Werner Koch 2015-10-06 17:34:13 +02:00
parent 7faf45effc
commit 6cf80dc77e
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -53,7 +53,7 @@
/* Not every installation has gotten around to supporting CERTs /* Not every installation has gotten around to supporting CERTs
yet... */ yet... */
#ifndef T_CERT #ifndef T_CERT
#define T_CERT 37 # define T_CERT 37
#endif #endif
/* ADNS has no support for CERT yet. */ /* ADNS has no support for CERT yet. */
@ -69,7 +69,7 @@
string and returned at R_URL. If WANT_CERTTYPE is 0 this function string and returned at R_URL. If WANT_CERTTYPE is 0 this function
returns the first CERT found with a supported type; it is expected returns the first CERT found with a supported type; it is expected
that only one CERT record is used. If WANT_CERTTYPE is one of the that only one CERT record is used. If WANT_CERTTYPE is one of the
supported certtypes only records wih this certtype are considered supported certtypes only records with this certtype are considered
and the first found is returned. (R_KEY,R_KEYLEN) are optional. */ and the first found is returned. (R_KEY,R_KEYLEN) are optional. */
gpg_error_t gpg_error_t
get_dns_cert (const char *name, int want_certtype, get_dns_cert (const char *name, int want_certtype,
@ -282,15 +282,10 @@ get_dns_cert (const char *name, int want_certtype,
dlen = buf16_to_u16 (pt); dlen = buf16_to_u16 (pt);
pt += 2; pt += 2;
/* We asked for CERT and got something else - might be a /* Check the type and parse. */
CNAME, so loop around again. */ if (type == T_CERT)
if (type != T_CERT)
{ {
pt += dlen; /* We got a CERT type. */
continue;
}
/* The CERT type */
ctype = buf16_to_u16 (pt); ctype = buf16_to_u16 (pt);
pt += 2; pt += 2;
@ -347,7 +342,8 @@ get_dns_cert (const char *name, int want_certtype,
*r_fpr = NULL; *r_fpr = NULL;
goto leave; goto leave;
} }
memcpy (*r_url, &pt[*r_fprlen + 1], dlen - (*r_fprlen + 1)); memcpy (*r_url, &pt[*r_fprlen + 1],
dlen - (*r_fprlen + 1));
(*r_url)[dlen - (*r_fprlen + 1)] = '\0'; (*r_url)[dlen - (*r_fprlen + 1)] = '\0';
} }
else else
@ -357,9 +353,15 @@ get_dns_cert (const char *name, int want_certtype,
goto leave; goto leave;
} }
/* Neither type matches, so go around to the next answer. */ /* No subtype matches, so continue with the next answer. */
pt += dlen; pt += dlen;
} }
else
{
/* Not a requested type - might be a CNAME. Try next item. */
pt += dlen;
}
}
} }
leave: leave: