[evolution-data-server] [imapx] Fix read of uninitialized memory from g_str_has_prefix



commit 837e469f23fbc4cf3590ee2e19a961f006d72bda
Author: Milan Crha <mcrha redhat com>
Date:   Fri Sep 16 09:31:25 2011 +0200

    [imapx] Fix read of uninitialized memory from g_str_has_prefix
    
    I caused this with a change of hiding LOGIN command debug prints,
    the ByteArray is not nul-terminated, thus later strlen use in
    g_str_has_prefix was reading out of bounds.

 camel/providers/imapx/camel-imapx-server.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 6a23d18..8871f80 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -843,7 +843,7 @@ camel_imapx_command_close (CamelIMAPXCommand *ic)
 
 		byte_array = camel_stream_mem_get_byte_array (ic->mem);
 
-		if (g_str_has_prefix ((const gchar *) byte_array->data, "LOGIN")) {
+		if (byte_array->len > 5 && g_ascii_strncasecmp ((const gchar *) byte_array->data, "LOGIN", 5)) {
 			c(ic->is->tagprefix, "completing command buffer is [%d] 'LOGIN...'\n", byte_array->len);
 		} else {
 			c(ic->is->tagprefix, "completing command buffer is [%d] '%.*s'\n", byte_array->len, (gint)byte_array->len, byte_array->data);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]