commit 45df2c7: [Minor] Do not serve absent dkim private keys from LRU cache

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Jan 21 13:07:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-01-21 13:04:48 +0000
URL: https://github.com/rspamd/rspamd/commit/45df2c78a87700a7501fb889d5c2791b0d354348 (HEAD -> master)

[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) {


More information about the Commits mailing list