authd: pass in uint32_t rid's.

This commit is contained in:
Elizabeth Myers 2016-03-27 17:28:26 -05:00
parent ee7f92714a
commit 26d491b95f
4 changed files with 17 additions and 12 deletions

View file

@ -53,6 +53,7 @@ static void
handle_stat(int parc, char *parv[]) handle_stat(int parc, char *parv[])
{ {
authd_stat_handler handler; authd_stat_handler handler;
long lrid;
if(parc < 3) if(parc < 3)
{ {
@ -60,10 +61,16 @@ handle_stat(int parc, char *parv[])
return; return;
} }
if((lrid = strtol(parv[1], NULL, 16)) > UINT32_MAX)
{
warn_opers(L_CRIT, "BUG: handle_stat got a rid that was too large: %lx", lrid);
return;
}
if (!(handler = authd_stat_handlers[(unsigned char)parv[2][0]])) if (!(handler = authd_stat_handlers[(unsigned char)parv[2][0]]))
return; return;
handler(parv[1], parv[2][0]); handler((uint32_t)lrid, parv[2][0]);
} }
static void static void

View file

@ -40,7 +40,7 @@ struct auth_opts_handler
extern rb_helper *authd_helper; extern rb_helper *authd_helper;
typedef void (*authd_cmd_handler)(int parc, char *parv[]); typedef void (*authd_cmd_handler)(int parc, char *parv[]);
typedef void (*authd_stat_handler)(const char *rid, const char letter); typedef void (*authd_stat_handler)(uint32_t rid, const char letter);
typedef void (*authd_reload_handler)(const char letter); typedef void (*authd_reload_handler)(const char letter);
extern authd_cmd_handler authd_cmd_handlers[256]; extern authd_cmd_handler authd_cmd_handlers[256];

View file

@ -252,17 +252,15 @@ handle_resolve_dns(int parc, char *parv[])
} }
void void
enumerate_nameservers(const char *rid, const char letter) enumerate_nameservers(uint32_t rid, const char letter)
{ {
char buf[(HOSTIPLEN + 1) * IRCD_MAXNS]; char buf[(HOSTIPLEN + 1) * IRCD_MAXNS];
char *c = buf;
size_t s = 0; size_t s = 0;
uint32_t i_rid = (uint32_t)strtol(rid, NULL, 16);
if (!irc_nscount) if (!irc_nscount)
{ {
/* Shouldn't happen */ /* Shouldn't happen */
stats_error(i_rid, letter, "NONAMESERVERS"); stats_error(rid, letter, "NONAMESERVERS");
return; return;
} }
@ -276,19 +274,19 @@ enumerate_nameservers(const char *rid, const char letter)
if (!addr[0]) if (!addr[0])
{ {
/* Shouldn't happen */ /* Shouldn't happen */
stats_error(i_rid, letter, "INVALIDNAMESERVER"); stats_error(rid, letter, "INVALIDNAMESERVER");
return; return;
} }
addrlen = strlen(addr) + 1; addrlen = strlen(addr) + 1;
(void)snprintf(c, sizeof(buf) - s, "%s ", addr); (void)snprintf(&buf[s], sizeof(buf) - s, "%s ", addr);
c += addrlen;
s += addrlen; s += addrlen;
} }
*(--c) = '\0'; if(s > 0)
buf[--s] = '\0';
stats_result(i_rid, letter, "%s", buf); stats_result(rid, letter, "%s", buf);
} }
void void

View file

@ -55,7 +55,7 @@ extern struct dns_query *lookup_ip(const char *host, int aftype, DNSCB callback,
extern void cancel_query(struct dns_query *query); extern void cancel_query(struct dns_query *query);
extern void handle_resolve_dns(int parc, char *parv[]); extern void handle_resolve_dns(int parc, char *parv[]);
extern void enumerate_nameservers(const char *rid, const char letter); extern void enumerate_nameservers(uint32_t rid, const char letter);
extern void reload_nameservers(const char letter); extern void reload_nameservers(const char letter);
#endif #endif