]> source.dussan.org Git - rspamd.git/commitdiff
Avoid using base64 as it can contain path symbols, use hex instead.
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Thu, 17 Nov 2011 16:10:25 +0000 (19:10 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Thu, 17 Nov 2011 16:10:25 +0000 (19:10 +0300)
src/kvstorage_file.c

index 14ae8d3b4d8befc68378c7c14d9d490d3ea99972..3460c213fb7cd8b099432f1574841f3cf26c0ab8 100644 (file)
@@ -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;