diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-15 17:38:25 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-15 17:38:25 +0000 |
commit | 6ffffe0d5f155aa5d212df92d97c62e2de71baa3 (patch) | |
tree | 90bdcfc42f39f3fc0245704c5c7bed499731a1f6 | |
parent | dd80be02e04635dfc1e62de86b36a229b12f4c9c (diff) | |
download | rspamd-6ffffe0d5f155aa5d212df92d97c62e2de71baa3.tar.gz rspamd-6ffffe0d5f155aa5d212df92d97c62e2de71baa3.zip |
[Minor] Check mmap return code
-rw-r--r-- | src/controller.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/controller.c b/src/controller.c index 78445c606..25eb54db8 100644 --- a/src/controller.c +++ b/src/controller.c @@ -345,13 +345,24 @@ rspamd_check_encrypted_password (struct rspamd_controller_worker_ctx *ctx, if (cache->len == 0) { /* Mmap region */ +#ifdef MAP_NOCORE + m = mmap (NULL, password->len, PROT_WRITE, + MAP_PRIVATE | MAP_ANON | MAP_NOCORE, -1, 0); +#else m = mmap (NULL, password->len, PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); - memcpy (m, password->begin, password->len); - (void)mprotect (m, password->len, PROT_READ); - (void)mlock (m, password->len); - cache->begin = m; - cache->len = password->len; +#endif + if (m != MAP_FAILED) { + memcpy (m, password->begin, password->len); + (void)mprotect (m, password->len, PROT_READ); + (void)mlock (m, password->len); + cache->begin = m; + cache->len = password->len; + } + else { + msg_err_ctx ("cannot store cached password, mmap failed: %s", + strerror (errno)); + } } } |