]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Check mmap return code
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 15 Jan 2017 17:38:25 +0000 (17:38 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 15 Jan 2017 17:38:25 +0000 (17:38 +0000)
src/controller.c

index 78445c6062c9196bdb983f76547aa134b232e92c..25eb54db8a20ac36c6d4faac0925ac90c18e8e84 100644 (file)
@@ -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));
+                       }
                }
        }