]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Do not serve absent dkim private keys from LRU cache
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 21 Jan 2019 13:04:48 +0000 (13:04 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 21 Jan 2019 13:04:48 +0000 (13:04 +0000)
src/libserver/dkim.c

index c70b0bbc0e22a0a58a987c44c5b64e7461e7a906..4b49d1e6f0fca74db5df55ffb56b5378de6149a8 100644 (file)
@@ -2736,11 +2736,16 @@ rspamd_dkim_sign_key_maybe_invalidate (rspamd_dkim_sign_key_t *key,
        if (type == RSPAMD_DKIM_SIGN_KEY_FILE) {
                gchar fpath[PATH_MAX];
 
+               if (len >= PATH_MAX) {
+                       /* Bad thing */
+                       return TRUE;
+               }
+
                rspamd_snprintf (fpath, sizeof (fpath), "%*s", (gint) len, what);
 
                if (stat (fpath, &st) == -1) {
-                       /* Prefer to use cached key since it is absent on FS */
-                       return FALSE;
+                       /* Wrong: do NOT prefer to use cached key since it is absent on FS */
+                       return TRUE;
                }
 
                if (st.st_mtime > key->mtime) {