Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion inc/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extern HOST_TYPE host_type(CSTR host, short int *dotsCountPtr);
extern BOOL year_is_leap(const int year);
extern BOOL validate_date(const int dateYear, const int dateMonth, const int dateDay);

extern char *expand_ipv6(CSTR input);
extern void expand_ipv6(CSTR input, STR output, size_t output_size);

extern char *convert_time(char *buffer, size_t len, time_t timeSpan, const LANG_ID langID);
extern char *expire_left(char *buffer, size_t len, time_t expiry);
Expand Down
18 changes: 7 additions & 11 deletions src/crypt_userhost.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ STR crypt_userhost(CSTR real, HOST_TYPE htype, short int dotsCount) {

size_t len, virlen;
int32_t hash;
char *ptr;
char *ptr, *expanded_real = real;
char expanded_real_buf[40];

#define MAX_DSN_HOST_LEN 64

Expand All @@ -291,10 +292,11 @@ STR crypt_userhost(CSTR real, HOST_TYPE htype, short int dotsCount) {

TRACE();
if (htype == htIPv6) {
len = str_len(expand_ipv6(real));
} else {
len = str_len(real);

expand_ipv6(real, expanded_real_buf, sizeof(expanded_real_buf));
expanded_real = expanded_real_buf;
}
len = str_len(expanded_real);
virlen = len + CRYPT_NETNAME_LEN + HIDEHOST_CHECKSUM_LEN + 2;

if (virlen > hidehost_buffer_size) {
Expand All @@ -305,11 +307,7 @@ STR crypt_userhost(CSTR real, HOST_TYPE htype, short int dotsCount) {

// generazione crypt

if (htype == htIPv6) {
hash = crypt_hash_SHA1(expand_ipv6(real), len, hidehost_crypt_buffer, hidehost_crypt_buffer_size);
} else {
hash = crypt_hash_SHA1(real, len, hidehost_crypt_buffer, hidehost_crypt_buffer_size);
}
hash = crypt_hash_SHA1(expanded_real, len, hidehost_crypt_buffer, hidehost_crypt_buffer_size);

// creazione stringa "criptata"

Expand Down Expand Up @@ -337,8 +335,6 @@ STR crypt_userhost(CSTR real, HOST_TYPE htype, short int dotsCount) {
struct in6_addr ip6addr;

char ip6buffer[INET6_ADDRSTRLEN];
strncpy(ip6buffer, expand_ipv6(real), sizeof(ip6buffer));

memset(ip6buffer, 0, sizeof(ip6buffer));
inet_pton(AF_INET6, real, &ip6addr);
memset(&(ip6addr.s6_addr[6]), 0, 10);
Expand Down
14 changes: 6 additions & 8 deletions src/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2158,20 +2158,20 @@ HOST_TYPE host_type(CSTR host, short int *dotsCountPtr) {
* compact form to its complete form. *
*********************************************************/

char *expand_ipv6(const char *input) {
void expand_ipv6(CSTR input, STR output, size_t output_size) {

char output[40];
char *ptr = output;
char *ptr;
int i = 0, colons, len;

memcpy(ptr, "0000:0000:0000:0000:0000:0000:0000:0000", 40);
memcpy(output, "0000:0000:0000:0000:0000:0000:0000:0000", 40);

colons = str_count(input, ':');

if (colons > 7) {

LOG_DEBUG_SNOOP("Warning: IPv6 %s is invalid!", input);
return str_duplicate(input);
strncpy(output, input, output_size - 1);
output[output_size - 1] = '\0';
return;
}

len = strlen(input);
Expand Down Expand Up @@ -2208,8 +2208,6 @@ char *expand_ipv6(const char *input) {
input--;
len--;
}

return str_duplicate(output);
}


Expand Down
5 changes: 2 additions & 3 deletions src/operserv.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ void check_clones_v6(const User *newUser) {
memset(clone_nicks, 0, sizeof(clone_nicks));
memset(tmp_clones, 0, sizeof(tmp_clones));

strncpy(ipbuf, expand_ipv6(get_ip6(newUser->ipv6)), 42);
expand_ipv6(get_ip6(newUser->ipv6), ipbuf, sizeof(ipbuf));
idx = CONF_CLONE_SCAN_V6 * 5;

ipbuf[idx++] = '*';
Expand All @@ -569,8 +569,7 @@ void check_clones_v6(const User *newUser) {
if (FlagUnset(userIPv6_item->user->flags, USER_FLAG_HAS_IPV6))
continue;

strncpy(ip_clonebuf, expand_ipv6(get_ip6(userIPv6_item->user->ipv6)), 42);
ip_clonebuf[41] = '\0';
expand_ipv6(get_ip6(userIPv6_item->user->ipv6), ip_clonebuf, sizeof(ip_clonebuf));

if (str_match_wild_nocase(ipbuf, ip_clonebuf)) {

Expand Down
Loading