]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib/data-stack - in panic scenarios, use the panic memory buffer
authorPhil Carmody <phil@dovecot.fi>
Thu, 14 Dec 2017 22:44:51 +0000 (00:44 +0200)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 7 Aug 2018 12:27:02 +0000 (15:27 +0300)
Signed-off-by: Phil Carmody <phil@dovecot.fi>
src/lib/data-stack.c

index 085f9e1e5f046480e486806bc4f61ed188b453a9..979c57ae2d22bce38ef56a6e291205f009e86c08 100644 (file)
@@ -201,10 +201,9 @@ data_stack_frame_t t_push_named(const char *format, ...)
 static void block_canary_check(struct stack_block *block)
 {
        if (block->canary != BLOCK_CANARY) {
-               /* make sure i_panic() won't try to allocate from the
-                  same block */
-               current_block = mem_block_alloc(INITIAL_STACK_SIZE);
-               current_block->left = current_block->size;
+               /* Make sure i_panic() won't try to allocate from the
+                  same block by falling back onto our emergency block. */
+               current_block = &outofmem_area.block;
                i_panic("Corrupted data stack canary");
        }
 }
@@ -597,6 +596,7 @@ void data_stack_init(void)
 
        outofmem_area.block.size = outofmem_area.block.left =
                sizeof(outofmem_area) - sizeof(outofmem_area.block);
+       outofmem_area.block.canary = BLOCK_CANARY;
 
        current_block = mem_block_alloc(INITIAL_STACK_SIZE);
        current_block->left = current_block->size;