Skip to content
This repository was archived by the owner on Jun 6, 2021. It is now read-only.

Commit 71842e7

Browse files
committed
get_random_host_part: hash uid!user@host, rather than just uid
This should significantly reduce the chance for the same x-part to be reused after an ircd restart (unless, of course, the user is the same). Alternatively, we could hash just user@host, but then it would no longer be "random"-type cloaking, plus there's already ident-type cloaking.
1 parent 125b387 commit 71842e7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

util.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ const char *_decode_hex_ip(const char *hex)
3030

3131
const char *_get_random_host_part(user_t *u)
3232
{
33+
// UID, user, host, '!', '@', NUL
34+
static char user_buf[9 + USERLEN + HOSTLEN + 3];
3335
static char buf[PRF_OUT_LEN + 3];
3436

3537
strcpy(buf, "x-");
38+
snprintf(user_buf, sizeof user_buf, "%s!%s@%s", u->uid, u->user, u->host);
3639

3740
if (!prf_ready)
3841
{
@@ -48,7 +51,7 @@ const char *_get_random_host_part(user_t *u)
4851
uint8_t *out, const size_t outlen);
4952

5053
uint8_t out[PRF_OUT_LEN];
51-
siphash((unsigned char*)u->uid, strlen(u->uid), prf_key, out, PRF_OUT_LEN);
54+
siphash((unsigned char*)user_buf, strlen(user_buf), prf_key, out, PRF_OUT_LEN);
5255

5356
for (size_t i=0; i < PRF_OUT_LEN; ++i)
5457
{

0 commit comments

Comments
 (0)