--- camel/camel-mime-utils.c.orig 2009-03-03 11:54:16.000000000 +0100 +++ camel/camel-mime-utils.c 2009-03-03 11:55:46.000000000 +0100 @@ -356,7 +356,11 @@ camel_base64_encode_simple (const char * int state = 0, outlen; unsigned int save = 0; - out = g_malloc (len * 4 / 3 + 5); + if (len >= ((G_MAXSIZE - 1) / 4 - 1) * 3) + g_error("%s: input too large for Base64 encoding (%"G_GSIZE_FORMAT" chars)", + G_STRLOC, len); + + out = g_malloc ((len / 3 + 1) * 4 + 1); outlen = camel_base64_encode_close ((unsigned char *)data, len, FALSE, out, &state, &save); out[outlen] = '\0';