X-Git-Url: https://jfr.im/git/irc/rqf/shadowircd.git/blobdiff_plain/907468c485f837cb8442c32509c8efec8f3f43b1..4859b814a5d8e99a85a951c21360c6b4922920a6:/src/blacklist.c?ds=inline diff --git a/src/blacklist.c b/src/blacklist.c index 572cadd..e8c27c3 100644 --- a/src/blacklist.c +++ b/src/blacklist.c @@ -30,7 +30,6 @@ * 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" @@ -78,9 +77,9 @@ static void blacklist_dns_callback(void *vptr, struct DNSReply *reply) 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 < rb_current_time()) { @@ -117,8 +116,8 @@ static void blacklist_dns_callback(void *vptr, struct DNSReply *reply) static void initiate_blacklist_dnsquery(struct Blacklist *blptr, struct Client *client_p) { struct BlacklistClient *blcptr = rb_malloc(sizeof(struct BlacklistClient)); - char buf[IRCD_BUFSIZE]; - int ip[4]; + char buf[IRCD_RES_HOSTLEN + 1]; + uint8_t *ip; blcptr->blacklist = blptr; blcptr->client_p = client_p; @@ -126,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, "%u.%u.%u.%u.%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); @@ -154,7 +157,7 @@ struct Blacklist *new_blacklist(char *name, char *reject_reason) } else blptr->status &= ~CONF_ILLEGAL; - rb_strlcpy(blptr->host, name, HOSTLEN); + rb_strlcpy(blptr->host, name, IRCD_RES_HOSTLEN + 1); rb_strlcpy(blptr->reject_reason, reject_reason, IRCD_BUFSIZE); blptr->lastwarning = 0;