[Dovecot] Assertion failed: (pos < input->size)

Asheesh Laroia asheesh at asheesh.org
Mon Oct 22 20:16:32 EEST 2007


On Sun, 21 Oct 2007, Asheesh Laroia wrote:

> I fear that the real problem is in base64_decode, but for now I'm going 
> to sleep instead of drowsily being confused by a debugger.

When I add the attached patch, which just adds two asserts toward the end 
of base64_decode(), I can get base64_decode to admit that it advanced the 
pos pointer beyond where it should be.

The asserts are src_pos <= src_size because the loops will advance src_pos 
to the point where it is == src_size.  It'd be nice if that didn't happen, 
and the value of src_pos were always valid, but here I've shown that it 
gets advanced even beyond == !

(Earlier, I was asserting src_pos < src_size, and then every use of 
base64_decode caused the assertion to fail, so I couldn't even log in.)

I'm still testing with the Maildir I linked to last night.

It'd be great to know if these new asserts are reasonable, and if so, what 
sorts of code changes might make them stop failing. (-:

-- Asheesh.

--
It has long been an axiom of mine that the little things are infinitely
the most important.
 		-- Sir Arthur Conan Doyle, "A Case of Identity"
-------------- next part --------------
diff -r 1478fc5cf632 src/lib/base64.c
--- a/src/lib/base64.c	Sun Oct 21 20:36:35 2007 +0300
+++ b/src/lib/base64.c	Mon Oct 22 10:11:40 2007 -0700
@@ -128,6 +128,8 @@ int base64_decode(const void *src, size_
 		buffer_append(dest, output, 3);
 	}
 
+	i_assert(src_pos <= src_size);
+
 	for (; src_pos < src_size; src_pos++) {
 		if (!IS_EMPTY(src_c[src_pos]))
 			break;
@@ -136,6 +138,7 @@ int base64_decode(const void *src, size_
 	if (src_pos_r != NULL)
 		*src_pos_r = src_pos;
 
+	i_assert(src_pos <= src_size);
 	return ret;
 }
 


More information about the dovecot mailing list