diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-11-17 19:10:25 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-11-17 19:10:25 +0300 |
commit | 7a8ddd6a019b7289722c546f9c90961c70f2c91c (patch) | |
tree | cf9633957d5d8159ed3c0e3269b97717b6f9a3a8 | |
parent | af6dc0cb170aea3e773a94a040e0e1f3f24591cf (diff) | |
download | rspamd-7a8ddd6a019b7289722c546f9c90961c70f2c91c.tar.gz rspamd-7a8ddd6a019b7289722c546f9c90961c70f2c91c.zip |
Avoid using base64 as it can contain path symbols, use hex instead.
-rw-r--r-- | src/kvstorage_file.c | 11 |
1 files 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; |