Last attempt at fixing memory access for first line
authorJelmer Vernooij <jelmer@samba.org>
Sun, 21 Oct 2007 11:49:37 +0000 (13:49 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sun, 21 Oct 2007 11:49:37 +0000 (13:49 +0200)
src/listener.c

index be2126ab828cb00ee031fa112c01f84081fd9b95..87130ac237a757115346fe77bf3b0b56ba8fedb1 100644 (file)
@@ -172,15 +172,16 @@ static gboolean handle_client_detect(GIOChannel *ioc, struct pending_client *pc)
                        return status;
                }
 
-               complete = g_malloc(in_len+1);
+               complete = g_malloc(in_len+2);
                complete[0] = header[0];
                memcpy(complete+1, raw, in_len);
+               complete[in_len+2] = '\0';
                g_free(raw);
 
                if (iconv == (GIConv)-1) {
                        cvrt = complete;
                } else {
-                       cvrt = g_convert_with_iconv(complete, in_len+1, iconv, NULL, NULL, &error);
+                       cvrt = g_convert_with_iconv(complete, -1, iconv, NULL, NULL, &error);
                        if (cvrt == NULL) {
                                cvrt = complete;
                                status = G_IO_STATUS_ERROR;