<commit_before>#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>

#define __USE_GNU
#include <netdb.h>

#include <arpa/inet.h>
#include <stdlib.h>

#include <mopher.h>

#define BUFLEN 1024
#define RBL_BUCKETS 32

static sht_t *rbl_table;

static int
rbl_register(char *name, char *domain)
{
	if (sht_insert(rbl_table, name, domain))
	{
		log_error("rbl_register: sht_insert failed");
		return -1;
	}

	return 0;
}


int
rbl_query(milter_stage_t stage, char *name, var_t *attrs)
{
	char *domain;
	struct sockaddr_storage *addr;
	char *addrstr = NULL;
	char query[BUFLEN];
	struct addrinfo *ai = NULL;
	struct addrinfo hints;
	void *data = NULL;
	int e;
	char *b[4];
	char *p;
	int i;


	domain = sht_lookup(rbl_table, name);
	if (domain == NULL)
	{
		log_error("rbl_query: unknown rbl \"%s\"", name);
		goto error;
	}

	if (acl_symbol_dereference(attrs, "milter_hostaddr", &addr, NULL))
	{
		log_error("rbl_query: acl_symbol_dereference failed");
		goto error;
	}

	/*
	 * No IPv6 support yet.
	 */
	if (addr->ss_family != AF_INET)
	{
		log_error("rbl_query: address family not supported");
		goto error;
	}
		
	addrstr = util_addrtostr(addr);
	if (addrstr == NULL)
	{
		log_error("rbl_query: util_addrtostr failed");
		goto error;
	}

	/*
	 * Split the address bytes
	 */
	for(i = 0, p = addrstr; i < 4 && p != NULL; p = strchr(p, '.'), ++i) {
		if(*p == '.') {
			*p++ = 0;
		}

		b[i] = p;
	}

	/*
	 * Build query string
	 */
	snprintf(query, sizeof query, "%s.%s.%s.%s.%s", b[3], b[2], b[1], b[0],
	    domain);

	bzero(&hints, sizeof(hints));
	hints.ai_family = AF_INET;
	hints.ai_socktype = SOCK_DGRAM;

	e = getaddrinfo(query, NULL, &hints, &ai);
	if(e && e != EAI_NONAME && e != EAI_NODATA)
	{
		log_error("rbl_query: getaddrinfo: %s", gai_strerror(e));
		goto error;
	}

	/*
	 * EAI_NONAME || EAI_NODATA
	 */
	if (e)
	{
		log_debug("rbl_query: RBL record \"%s\" not found", query);
	}<commit_msg>rbl.c, rbl_query(): add missing goto<commit_after>#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>

#define __USE_GNU
#include <netdb.h>

#include <arpa/inet.h>
#include <stdlib.h>

#include <mopher.h>

#define BUFLEN 1024
#define RBL_BUCKETS 32

static sht_t *rbl_table;

static int
rbl_register(char *name, char *domain)
{
	if (sht_insert(rbl_table, name, domain))
	{
		log_error("rbl_register: sht_insert failed");
		return -1;
	}

	return 0;
}


int
rbl_query(milter_stage_t stage, char *name, var_t *attrs)
{
	char *domain;
	struct sockaddr_storage *addr;
	char *addrstr = NULL;
	char query[BUFLEN];
	struct addrinfo *ai = NULL;
	struct addrinfo hints;
	void *data = NULL;
	int e;
	char *b[4];
	char *p;
	int i;


	domain = sht_lookup(rbl_table, name);
	if (domain == NULL)
	{
		log_error("rbl_query: unknown rbl \"%s\"", name);
		goto error;
	}

	if (acl_symbol_dereference(attrs, "milter_hostaddr", &addr, NULL))
	{
		log_error("rbl_query: acl_symbol_dereference failed");
		goto error;
	}

	/*
	 * No IPv6 support yet.
	 */
	if (addr->ss_family != AF_INET)
	{
		log_error("rbl_query: address family not supported");
		goto error;
	}
		
	addrstr = util_addrtostr(addr);
	if (addrstr == NULL)
	{
		log_error("rbl_query: util_addrtostr failed");
		goto error;
	}

	/*
	 * Split the address bytes
	 */
	for(i = 0, p = addrstr; i < 4 && p != NULL; p = strchr(p, '.'), ++i) {
		if(*p == '.') {
			*p++ = 0;
		}

		b[i] = p;
	}

	/*
	 * Build query string
	 */
	snprintf(query, sizeof query, "%s.%s.%s.%s.%s", b[3], b[2], b[1], b[0],
	    domain);

	bzero(&hints, sizeof(hints));
	hints.ai_family = AF_INET;
	hints.ai_socktype = SOCK_DGRAM;

	e = getaddrinfo(query, NULL, &hints, &ai);
	if(e && e != EAI_NONAME && e != EAI_NODATA)
	{
		log_error("rbl_query: getaddrinfo: %s", gai_strerror(e));
		goto error;
	}

	/*
	 * EAI_NONAME || EAI_NODATA
	 */
	if (e)
	{
		log_debug("rbl_query: RBL record \"%s\" not found", query);
		goto error;
	}
{'fraction_non_alphanumeric': 0.17053867755935664, 'fraction_numerical': 0.008680112330865459, 'mean_word_length': 3.7433414043583535, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3990998', 'n_tokens_mistral': 1813, 'n_tokens_neox': 1684, 'n_words': 388}