ClearDynSpoof(client);
}
-#define HOSTLEN 63
-
static void
do_host_cloak_ip(const char *inbuf, char *outbuf)
{
int totalcount = 0;
int ipv6 = 0;
- strncpy(outbuf, inbuf, HOSTLEN);
+ rb_strlcpy(outbuf, inbuf, HOSTLEN + 1);
if (strchr(outbuf, ':'))
{
* the actual cloaking would get ugly
*/
for (tptr = outbuf; *tptr != '\0'; tptr++)
- {
- if (*tptr == ':') {
+ if (*tptr == ':')
totalcount++;
- }
- }
}
else if (!strchr(outbuf, '.'))
- {
return;
- }
for (tptr = outbuf; *tptr != '\0'; tptr++)
{
continue;
}
- switch (ipv6)
- {
- case 1:
- if (sepcount < totalcount / 2)
- break;
- case 0:
- if (sepcount < 2)
- break;
- default:
- *tptr = chartable[(*tptr + accum) % 20];
+ if (ipv6 && sepcount < totalcount / 2)
+ continue;
- }
+ if (!ipv6 && sepcount < 2)
+ continue;
+ *tptr = chartable[(*tptr + accum) % 20];
accum = (accum << 1) | (accum >> 31);
}
}
char *tptr;
uint32_t accum = fnv_hash((const unsigned char*) inbuf, 32);
- strncpy(outbuf, inbuf, HOSTLEN);
+ rb_strlcpy(outbuf, inbuf, HOSTLEN + 1);
/* pass 1: scramble first section of hostname using base26
* alphabet toasted against the FNV hash of the string.
for (tptr = outbuf; *tptr != '\0'; tptr++)
{
if (isdigit(*tptr))
- {
- *tptr = (*tptr + accum) % 10;
- }
+ *tptr = '0' + (*tptr + accum) % 10;
accum = (accum << 1) | (accum >> 31);
}
}
if (strcmp(source_p->host, source_p->localClient->mangledhost))
{
- rb_strlcpy(source_p->host, source_p->localClient->mangledhost, HOSTLEN);
+ rb_strlcpy(source_p->host, source_p->localClient->mangledhost, HOSTLEN + 1);
distribute_hostchange(source_p);
}
else /* not really nice, but we need to send this numeric here */
if (source_p->localClient->mangledhost != NULL &&
!strcmp(source_p->host, source_p->localClient->mangledhost))
{
- rb_strlcpy(source_p->host, source_p->orighost, HOSTLEN);
+ rb_strlcpy(source_p->host, source_p->orighost, HOSTLEN + 1);
distribute_hostchange(source_p);
}
}
source_p->umodes &= ~user_modes['h'];
return;
}
- source_p->localClient->mangledhost = rb_malloc(HOSTLEN);
+ source_p->localClient->mangledhost = rb_malloc(HOSTLEN + 1);
if (!irccmp(source_p->orighost, source_p->sockhost))
do_host_cloak_ip(source_p->orighost, source_p->localClient->mangledhost);
else