#include "ircd_log.h"
#include "ircd_osdep.h"
#include "ircd_reply.h"
+#include "ircd_snprintf.h"
#include "ircd_string.h"
#include "msg.h"
#include "numeric.h"
#include "s_debug.h"
#include "s_misc.h"
#include "send.h"
-#include "sprintf_irc.h"
#include "struct.h"
#include "support.h"
#include "sys.h"
/* Socket callback for resolver */
static void res_callback(struct Event* ev)
{
- assert(ev_type(ev) == ET_READ);
+ assert(ev_type(ev) == ET_READ || ev_type(ev) == ET_ERROR);
resolver_read();
}
spare_fd = open("/dev/null",O_RDONLY,0);
if ((spare_fd < 0) || (spare_fd > 255)) {
char sparemsg[80];
- sprintf_irc(sparemsg, "invalid spare_fd %d", spare_fd);
+ ircd_snprintf(0, sparemsg, sizeof(sparemsg), "invalid spare_fd %d",
+ spare_fd);
server_restart(sparemsg);
}
requestListHead = requestListTail = 0;
/* initiate the resolver timers */
- timer_add(&resExpireDNS, expire_DNS_callback, 0, TT_RELATIVE, 1);
- timer_add(&resExpireCache, expire_cache_callback, 0, TT_RELATIVE, 1);
+ timer_add(timer_init(&resExpireDNS), expire_DNS_callback, 0,
+ TT_RELATIVE, 1);
+ timer_add(timer_init(&resExpireCache), expire_cache_callback, 0,
+ TT_RELATIVE, 1);
errno = h_errno = 0;
assert(0 != addr);
cp = (const unsigned char*) &addr->s_addr;
- sprintf_irc(ipbuf, "%u.%u.%u.%u.in-addr.arpa.",
- (unsigned int)(cp[3]), (unsigned int)(cp[2]),
- (unsigned int)(cp[1]), (unsigned int)(cp[0]));
+ ircd_snprintf(0, ipbuf, sizeof(ipbuf), "%u.%u.%u.%u.in-addr.arpa.",
+ (unsigned int)(cp[3]), (unsigned int)(cp[2]),
+ (unsigned int)(cp[1]), (unsigned int)(cp[0]));
if (!request) {
request = make_request(query);
u_char* current; /* current position in buf */
char** alias; /* alias list */
char** addr; /* address list */
+ char** base_addr; /* original pointer to address list */
char* name; /* pointer to name string */
char* address; /* pointer to address */
+ char* base_address; /* original pointer to address */
char* endp; /* end of our buffer */
int query_class; /* answer class */
int type; /* answer type */
int n; /* temp count */
int addr_count = 0; /* number of addresses in hostent */
int alias_count = 0; /* number of aliases in hostent */
+ int t_ptr_seen = 0; /* Seen a T_PTR in proc_answer? */
struct hostent* hp; /* hostent getting filled */
assert(0 != request);
++addr;
++addr_count;
}
+ base_addr = addr;
/*
* make address point to first available address slot
*/
address = request->he.buf + ADDRS_OFFSET +
(sizeof(struct in_addr) * addr_count);
+ base_address = address;
+
/*
* find the end of the alias list
*/
case T_A:
/*
* check for invalid rd_length or too many addresses
+ * ignore T_A relies if looking for a T_PTR
*/
+ if (t_ptr_seen)
+ return answer_count;
if (rd_length != sizeof(struct in_addr))
return answer_count;
if (++addr_count < RES_MAXADDRS) {
++answer_count;
break;
case T_PTR:
+ t_ptr_seen = 1;
+ addr_count = 0;
+ addr = base_addr;
+ *addr = 0;
+ address = base_address;
n = dn_expand(buf, eob, current, hostbuf, sizeof(hostbuf));
if (n < 0) {
/*
*/
static void update_list(struct ResRequest* request, struct CacheEntry* cachep)
{
-#if 0
- struct CacheEntry** cpp;
-#endif
struct CacheEntry* cp = cachep;
char* s;
char* t;
* If found, move the entry to the top of the list and return.
*/
++cainfo.ca_updates;
-#if 0
- for (cpp = &cacheTop; *cpp; cpp = &((*cpp)->list_next)) {
- if (cp == *cpp)
- break;
- }
- if (!*cpp)
- return;
- *cpp = cp->list_next;
- cp->list_next = cacheTop;
- cacheTop = cp;
-#endif
if (!request)
return;
* shouldn't happen but it just might...
*/
assert(0 != hp->h_name);
- assert(0 != hp->h_addr_list[0]);
+/* assert(0 != hp->h_addr_list[0]); */
if (!hp->h_name || !hp->h_addr_list[0])
return NULL;
/*