From 45df2c78a87700a7501fb889d5c2791b0d354348 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 21 Jan 2019 13:04:48 +0000 Subject: [PATCH] [Minor] Do not serve absent dkim private keys from LRU cache --- src/libserver/dkim.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libserver/dkim.c b/src/libserver/dkim.c index c70b0bbc0..4b49d1e6f 100644 --- a/src/libserver/dkim.c +++ b/src/libserver/dkim.c @@ -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) { -- 2.39.5