pkgsrc-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
chat/bitlbee-3.0.3 problem with msn
Hi,
the bitlbee bug ticket #850 has been closed but a new release is not
available yet (http://bugs.bitlbee.org/bitlbee/ticket/850).
Find the attached patch, msn now connects.
Best,
--
Frédéric Fauberteau
$NetBSD$
--- lib/http_client.c.orig 2011-06-12 11:53:51.000000000 +0000
+++ lib/http_client.c
@@ -368,14 +368,25 @@ got_reply:
goto cleanup;
}
- /* Okay, this isn't fun! We have to rebuild the
request... :-( */
- new_request = g_malloc( req->request_length + strlen(
url->file ) );
-
+ /* Okay, this isn't fun! We have to rebuild the request... :-(
+ The new request will have the same amount of memory as the original,
+ allowing for a safe reuse of the original HTTP method. Further, the
+ addition of a new host may change the overall size. */
+ new_request = g_malloc( req->request_length + strlen( url->file ) +
strlen(url->host));
+
+ int method_len = strcspn(req->request, " ");
+ char *method = g_malloc(sizeof(char) * method_len + 1);
+ strncpy(method, req->request, method_len);
+ strcpy(method + method_len, "\0");
+
/* So, now I just allocated enough memory, so I'm
going to use strcat(), whether you like it or not.
:-) */
- sprintf( new_request, "GET %s HTTP/1.0", url->file );
+ sprintf( new_request, "%s %s HTTP/1.0", method,
url->file );
+
+ g_free(method);
+ /* Strip off the first original line. */
s = strstr( req->request, "\r\n" );
if( s == NULL )
{
@@ -384,8 +395,18 @@ got_reply:
g_free( url );
goto cleanup;
}
-
- strcat( new_request, s );
+ /* Add everything up to Host header. */
+ char* host_starts = strstr(s, "Host: ");
+ strncat(new_request, s, strlen(s) - strlen(host_starts));
+
+ /* Add new Host header. */
+ strcat(new_request, "Host: ");
+ strncat(new_request, url->host, strlen(url->host));
+
+ /* Add everything after original Host header. */
+ char* host_ends = strstr(host_starts, "\r\n");
+ strcat(new_request, host_ends);
+
new_host = g_strdup( url->host );
new_port = url->port;
new_proto = url->proto;
Home |
Main Index |
Thread Index |
Old Index