]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: data-stack - add vital sanity-preserving assert to t_pop
authorPhil Carmody <phil@dovecot.fi>
Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)
committerPhil Carmody <phil@dovecot.fi>
Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)
If something has re-ordered those two offsets, the following memset
will explode.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
src/lib/data-stack.c

index 99926c9dc33ffdac489a21f223f1bffe9e447ae5..53e6945d56807c61f793fff6298b23bccfc96661 100644 (file)
@@ -278,6 +278,7 @@ unsigned int t_pop(void)
                pos = current_block->size -
                        current_frame_block->block_space_used[frame_pos];
                used_size = current_block->size - current_block->lowwater;
+               i_assert(used_size >= pos);
                memset(STACK_BLOCK_DATA(current_block) + pos, CLEAR_CHR,
                       used_size - pos);
        }