X-Git-Url: https://jfr.im/git/irc/rqf/shadowircd.git/blobdiff_plain/38e6acddad741b38a475fe3d10dfffb3c6d6c639..b67bc679f3b28ce0f5facd85fd1c4bfb4065149e:/src/blacklist.c?ds=sidebyside diff --git a/src/blacklist.c b/src/blacklist.c index 6e0740a..d468a8f 100644 --- a/src/blacklist.c +++ b/src/blacklist.c @@ -30,14 +30,11 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: blacklist.c 2743 2006-11-10 15:15:00Z jilles $ */ #include "stdinc.h" #include "client.h" #include "res.h" -#include "tools.h" -#include "memory.h" #include "numeric.h" #include "reject.h" #include "s_conf.h" @@ -74,22 +71,22 @@ static void blacklist_dns_callback(void *vptr, struct DNSReply *reply) { sendto_realops_snomask(SNO_GENERAL, L_ALL, "blacklist_dns_callback(): blcptr->client_p->preClient (%s) is NULL", get_client_name(blcptr->client_p, HIDE_IP)); - MyFree(blcptr); + rb_free(blcptr); return; } if (reply != NULL) { - /* only accept 127.0.0.x as a listing */ + /* only accept 127.x.y.z as a listing */ if (reply->addr.ss_family == AF_INET && - !memcmp(&((struct sockaddr_in *)&reply->addr)->sin_addr, "\177\0\0", 3)) + !memcmp(&((struct sockaddr_in *)&reply->addr)->sin_addr, "\177", 1)) listed = TRUE; - else if (blcptr->blacklist->lastwarning + 3600 < CurrentTime) + else if (blcptr->blacklist->lastwarning + 3600 < rb_current_time()) { sendto_realops_snomask(SNO_GENERAL, L_ALL, "Garbage reply from blacklist %s", blcptr->blacklist->host); - blcptr->blacklist->lastwarning = CurrentTime; + blcptr->blacklist->lastwarning = rb_current_time(); } } @@ -108,19 +105,19 @@ static void blacklist_dns_callback(void *vptr, struct DNSReply *reply) if (rb_dlink_list_length(&blcptr->client_p->preClient->dnsbl_queries) == 0 && blcptr->client_p->flags & FLAGS_SENTUSER && !EmptyString(blcptr->client_p->name)) { char buf[USERLEN + 1]; - strlcpy(buf, blcptr->client_p->username, sizeof buf); + rb_strlcpy(buf, blcptr->client_p->username, sizeof buf); register_local_user(blcptr->client_p, blcptr->client_p, buf); } - MyFree(blcptr); + rb_free(blcptr); } /* XXX: no IPv6 implementation, not to concerned right now though. */ static void initiate_blacklist_dnsquery(struct Blacklist *blptr, struct Client *client_p) { - struct BlacklistClient *blcptr = MyMalloc(sizeof(struct BlacklistClient)); - char buf[IRCD_BUFSIZE]; - int ip[4]; + struct BlacklistClient *blcptr = rb_malloc(sizeof(struct BlacklistClient)); + char buf[IRCD_RES_HOSTLEN + 1]; + uint8_t *ip; blcptr->blacklist = blptr; blcptr->client_p = client_p; @@ -128,11 +125,15 @@ static void initiate_blacklist_dnsquery(struct Blacklist *blptr, struct Client * blcptr->dns_query.ptr = blcptr; blcptr->dns_query.callback = blacklist_dns_callback; - /* XXX: yes I know this is bad, I don't really care right now */ - sscanf(client_p->sockhost, "%d.%d.%d.%d", &ip[3], &ip[2], &ip[1], &ip[0]); + ip = (uint8_t *)&((struct sockaddr_in *)&client_p->localClient->ip)->sin_addr.s_addr; /* becomes 2.0.0.127.torbl.ahbl.org or whatever */ - rb_snprintf(buf, IRCD_BUFSIZE, "%d.%d.%d.%d.%s", ip[0], ip[1], ip[2], ip[3], blptr->host); + rb_snprintf(buf, sizeof buf, "%d.%d.%d.%d.%s", + (unsigned int) ip[3], + (unsigned int) ip[2], + (unsigned int) ip[1], + (unsigned int) ip[0], + blptr->host); gethost_byname_type(buf, &blcptr->dns_query, T_A); @@ -151,13 +152,13 @@ struct Blacklist *new_blacklist(char *name, char *reject_reason) blptr = find_blacklist(name); if (blptr == NULL) { - blptr = MyMalloc(sizeof(struct Blacklist)); + blptr = rb_malloc(sizeof(struct Blacklist)); rb_dlinkAddAlloc(blptr, &blacklist_list); } else blptr->status &= ~CONF_ILLEGAL; - strlcpy(blptr->host, name, HOSTLEN); - strlcpy(blptr->reject_reason, reject_reason, IRCD_BUFSIZE); + rb_strlcpy(blptr->host, name, IRCD_RES_HOSTLEN + 1); + rb_strlcpy(blptr->reject_reason, reject_reason, IRCD_BUFSIZE); blptr->lastwarning = 0; return blptr; @@ -169,7 +170,7 @@ void unref_blacklist(struct Blacklist *blptr) if (blptr->status & CONF_ILLEGAL && blptr->refcount <= 0) { rb_dlinkFindDestroy(blptr, &blacklist_list); - MyFree(blptr); + rb_free(blptr); } } @@ -203,7 +204,7 @@ void abort_blacklist_queries(struct Client *client_p) rb_dlinkDelete(&blcptr->node, &client_p->preClient->dnsbl_queries); unref_blacklist(blcptr->blacklist); delete_resolver_queries(&blcptr->dns_query); - MyFree(blcptr); + rb_free(blcptr); } } @@ -220,7 +221,7 @@ void destroy_blacklists(void) blptr->status |= CONF_ILLEGAL; else { - MyFree(ptr->data); + rb_free(ptr->data); rb_dlinkDestroy(ptr, &blacklist_list); } }