X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fnames-net.c;h=95a6fd2654cd26cb378efad050b8fbd225bc1e07;hb=3444b81f6b0e83eacb391e10b41f9a7b60e66f4e;hp=9de73a7271dccbb486d5e1a1d5784390a3ff5f3d;hpb=b14cda81278fb0435fbb4c93b64122ee28dcb7bb;p=pciutils.git diff --git a/lib/names-net.c b/lib/names-net.c index 9de73a7..95a6fd2 100644 --- a/lib/names-net.c +++ b/lib/names-net.c @@ -8,15 +8,25 @@ #include #include +#include #include "internal.h" #include "names.h" #ifdef PCI_USE_DNS +/* + * Our definition of BYTE_ORDER confuses arpa/nameser_compat.h on + * Solaris so we must undef it before including arpa/nameser.h. + */ +#ifdef PCI_OS_SUNOS +#undef BYTE_ORDER +#endif + #include #include #include +#include /* * Unfortunately, there are no portable functions for DNS RR parsing, @@ -36,19 +46,19 @@ enum dns_section { struct dns_state { u16 counts[DNS_NUM_SECTIONS]; - u8 *sections[DNS_NUM_SECTIONS+1]; - u8 *sec_ptr, *sec_end; + byte *sections[DNS_NUM_SECTIONS+1]; + byte *sec_ptr, *sec_end; /* Result of dns_parse_rr(): */ u16 rr_type; u16 rr_class; u32 rr_ttl; u16 rr_len; - u8 *rr_data; + byte *rr_data; }; -static u8 * -dns_skip_name(u8 *p, u8 *end) +static byte * +dns_skip_name(byte *p, byte *end) { while (p < end) { @@ -71,10 +81,11 @@ dns_skip_name(u8 *p, u8 *end) } static int -dns_parse_packet(struct dns_state *s, u8 *p, unsigned int plen) +dns_parse_packet(struct dns_state *s, byte *p, unsigned int plen) { - u8 *end = p + plen; - unsigned int i, j, x, len; + byte *end = p + plen; + unsigned int i, j, len; + unsigned int UNUSED x; #if 0 /* Dump the packet */ @@ -185,7 +196,7 @@ char default: return NULL; } - sprintf(dnsname, "%s.%s", name, domain); + sprintf(dnsname, "%.100s.%.100s", name, domain); a->debug("Resolving %s\n", dnsname); if (!resolver_inited) @@ -196,7 +207,7 @@ char res = res_query(dnsname, ns_c_in, ns_t_txt, answer, sizeof(answer)); if (res < 0) { - a->debug("\tfailed, h_errno=%d\n", _res.res_h_errno); + a->debug("\tfailed, h_errno=%d\n", h_errno); return NULL; } if (dns_parse_packet(&ds, answer, res) < 0)