ip_cloaking: fix HOSTLEN buffer lengths,

could have truncated one char it shouldn't
This commit is contained in:
Jilles Tjoelker 2008-09-19 23:41:22 +02:00
parent 799483e7ea
commit 8109e8e320
1 changed files with 5 additions and 7 deletions

View File

@ -66,8 +66,6 @@ distribute_hostchange(struct Client *client)
ClearDynSpoof(client); ClearDynSpoof(client);
} }
#define HOSTLEN 63
static void static void
do_host_cloak_ip(const char *inbuf, char *outbuf) do_host_cloak_ip(const char *inbuf, char *outbuf)
{ {
@ -79,7 +77,7 @@ do_host_cloak_ip(const char *inbuf, char *outbuf)
int totalcount = 0; int totalcount = 0;
int ipv6 = 0; int ipv6 = 0;
strncpy(outbuf, inbuf, HOSTLEN); rb_strlcpy(outbuf, inbuf, HOSTLEN + 1);
if (strchr(outbuf, ':')) if (strchr(outbuf, ':'))
{ {
@ -137,7 +135,7 @@ do_host_cloak_host(const char *inbuf, char *outbuf)
char *tptr; char *tptr;
uint32_t accum = fnv_hash((const unsigned char*) inbuf, 32); 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 /* pass 1: scramble first section of hostname using base26
* alphabet toasted against the FNV hash of the string. * alphabet toasted against the FNV hash of the string.
@ -192,7 +190,7 @@ check_umode_change(void *vdata)
} }
if (strcmp(source_p->host, source_p->localClient->mangledhost)) 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); distribute_hostchange(source_p);
} }
else /* not really nice, but we need to send this numeric here */ else /* not really nice, but we need to send this numeric here */
@ -204,7 +202,7 @@ check_umode_change(void *vdata)
if (source_p->localClient->mangledhost != NULL && if (source_p->localClient->mangledhost != NULL &&
!strcmp(source_p->host, source_p->localClient->mangledhost)) !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); distribute_hostchange(source_p);
} }
} }
@ -220,7 +218,7 @@ check_new_user(void *vdata)
source_p->umodes &= ~user_modes['h']; source_p->umodes &= ~user_modes['h'];
return; return;
} }
source_p->localClient->mangledhost = rb_malloc(HOSTLEN); source_p->localClient->mangledhost = rb_malloc(HOSTLEN + 1);
if (!irccmp(source_p->orighost, source_p->sockhost)) if (!irccmp(source_p->orighost, source_p->sockhost))
do_host_cloak_ip(source_p->orighost, source_p->localClient->mangledhost); do_host_cloak_ip(source_p->orighost, source_p->localClient->mangledhost);
else else