aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-15 17:38:25 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-15 17:38:25 +0000
commit6ffffe0d5f155aa5d212df92d97c62e2de71baa3 (patch)
tree90bdcfc42f39f3fc0245704c5c7bed499731a1f6
parentdd80be02e04635dfc1e62de86b36a229b12f4c9c (diff)
downloadrspamd-6ffffe0d5f155aa5d212df92d97c62e2de71baa3.tar.gz
rspamd-6ffffe0d5f155aa5d212df92d97c62e2de71baa3.zip
[Minor] Check mmap return code
-rw-r--r--src/controller.c21
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));
+ }
}
}