From 7a8ddd6a019b7289722c546f9c90961c70f2c91c Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 17 Nov 2011 19:10:25 +0300 Subject: [PATCH] Avoid using base64 as it can contain path symbols, use hex instead. --- src/kvstorage_file.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/kvstorage_file.c b/src/kvstorage_file.c index 14ae8d3b4..3460c213f 100644 --- a/src/kvstorage_file.c +++ b/src/kvstorage_file.c @@ -63,7 +63,7 @@ static gboolean get_file_name (struct rspamd_file_backend *db, gchar *key, guint keylen, gchar *filebuf, guint buflen) { gchar *p = filebuf, *end = filebuf + buflen, - *k = key; + *k = key, t; guint i; /* First copy backend dirname to file buf */ @@ -84,13 +84,18 @@ get_file_name (struct rspamd_file_backend *db, gchar *key, guint keylen, gchar * } /* Now we have directory, append base64 encoded filename */ k = key; - if (end - p < (keylen / 3 + 1) * 4 + 4 + 1) { + if (end - p < keylen * 2 + 1) { /* Filebuf is not large enough */ return FALSE; } i = 0; - p += g_base64_encode_step (key, keylen, FALSE, p, &i, &i); + while (k < key + keylen) { + t = *k; + *p++ = hexdigits[(t >> 4) & 0xf]; + *p++ = hexdigits[t & 0xf]; + k ++; + } *p = '\0'; return TRUE; -- 2.39.5