From 25c4c78e2ddad482dfc9d5a104f76325fcc2f8e5 Mon Sep 17 00:00:00 2001 From: Jason Copenhaver Date: Fri, 16 Jan 2015 16:50:24 -0300 Subject: Fix compiler warnings on Cygwin and Mac OS X. * Don't use PIE/PIC on Cygwin/Darwin unless specified as these platforms don't support it. * Cleanup warnings for 'make check' build. * Fix the type issue for getsockopt calls. * Fix enum warnings in Yahoo libs on Mac OS X. --- lib/ns_parse.c | 2 +- lib/proxy.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/ns_parse.c b/lib/ns_parse.c index ba45d513..0462b67e 100644 --- a/lib/ns_parse.c +++ b/lib/ns_parse.c @@ -18,7 +18,7 @@ #include "bitlbee.h" #ifndef lint -static const char rcsid[] = "$Id: ns_parse.c,v 1.10 2009/01/23 19:59:16 each Exp $"; +//static const char rcsid[] = "$Id: ns_parse.c,v 1.10 2009/01/23 19:59:16 each Exp $"; #endif #ifdef HAVE_RESOLV_A diff --git a/lib/proxy.c b/lib/proxy.c index 86bb0dcc..2adcde3b 100644 --- a/lib/proxy.c +++ b/lib/proxy.c @@ -65,7 +65,7 @@ static int proxy_connect_none(const char *host, unsigned short port_, struct PHB static gboolean gaim_io_connected(gpointer data, gint source, b_input_condition cond) { struct PHB *phb = data; - unsigned int len; + socklen_t len; int error = ETIMEDOUT; len = sizeof(error); @@ -213,7 +213,7 @@ static gboolean http_canwrite(gpointer data, gint source, b_input_condition cond { char cmd[384]; struct PHB *phb = data; - unsigned int len; + socklen_t len; int error = ETIMEDOUT; if (phb->inpa > 0) b_event_remove(phb->inpa); @@ -308,7 +308,7 @@ static gboolean s4_canwrite(gpointer data, gint source, b_input_condition cond) unsigned char packet[12]; struct hostent *hp; struct PHB *phb = data; - unsigned int len; + socklen_t len; int error = ETIMEDOUT; if (phb->inpa > 0) b_event_remove(phb->inpa); @@ -500,7 +500,7 @@ static gboolean s5_canwrite(gpointer data, gint source, b_input_condition cond) unsigned char buf[512]; int i; struct PHB *phb = data; - unsigned int len; + socklen_t len; int error = ETIMEDOUT; if (phb->inpa > 0) b_event_remove(phb->inpa); -- cgit v1.2.3 From 20c9c216b358f97b448282752df171820ff97ab1 Mon Sep 17 00:00:00 2001 From: dequis Date: Fri, 16 Jan 2015 16:50:24 -0300 Subject: Fix some more g_source_remove warnings, this time in proxy.c Both in gaim_io_connected(), visible when using an http proxy --- lib/proxy.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/proxy.c b/lib/proxy.c index 2adcde3b..addda16c 100644 --- a/lib/proxy.c +++ b/lib/proxy.c @@ -85,6 +85,7 @@ static gboolean gaim_io_connected(gpointer data, gint source, b_input_condition freeaddrinfo(phb->gai); closesocket(source); b_event_remove(phb->inpa); + phb->inpa = 0; if( phb->proxy_func ) phb->proxy_func(phb->proxy_data, -1, B_EV_IO_READ); else { @@ -96,6 +97,7 @@ static gboolean gaim_io_connected(gpointer data, gint source, b_input_condition freeaddrinfo(phb->gai); sock_make_blocking(source); b_event_remove(phb->inpa); + phb->inpa = 0; if( phb->proxy_func ) phb->proxy_func(phb->proxy_data, source, B_EV_IO_READ); else { -- cgit v1.2.3 From 840394e847eb4f72443facf8b923741698c3e9a6 Mon Sep 17 00:00:00 2001 From: dequis Date: Fri, 16 Jan 2015 16:50:24 -0300 Subject: http proxy: only check for "HTTP/1.x 200" in the status string It was checking for "Connection established" and some proxies use a different string, such as "Tunnel established" in polipo --- lib/proxy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/proxy.c b/lib/proxy.c index addda16c..2e0dc2cf 100644 --- a/lib/proxy.c +++ b/lib/proxy.c @@ -175,8 +175,8 @@ static int proxy_connect_none(const char *host, unsigned short port_, struct PHB /* Connecting to HTTP proxies */ -#define HTTP_GOODSTRING "HTTP/1.0 200 Connection established" -#define HTTP_GOODSTRING2 "HTTP/1.1 200 Connection established" +#define HTTP_GOODSTRING "HTTP/1.0 200" +#define HTTP_GOODSTRING2 "HTTP/1.1 200" static gboolean http_canread(gpointer data, gint source, b_input_condition cond) { -- cgit v1.2.3 From fed4f766c05e44e99917909b266c99c052ed9c3e Mon Sep 17 00:00:00 2001 From: dequis Date: Fri, 16 Jan 2015 16:50:25 -0300 Subject: Fix UTF8 nick truncation issues When nicks exceeded the length limit, they were cut at 24 bytes and that sometimes left invalid utf8 at the end, which made the nick_ok() validation fail and often broke those nicks completely. This adds a truncate_utf8 function to cut the string at a safe place Also, the method to deduplicate nicks when there's no more place to add underscores was changed to add "_XX" at the end, where XX are two random hex chars. The previous method in those cases was increasing the value of the first character of the nick... which leads to silly and confusing results (i.e. FacebookUser -> GacebookUser) --- lib/misc.c | 9 +++++++++ lib/misc.h | 1 + 2 files changed, 10 insertions(+) (limited to 'lib') diff --git a/lib/misc.c b/lib/misc.c index 02b1814c..6fedb48f 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -779,3 +779,12 @@ char *get_rfc822_header( const char *text, const char *header, int len ) return NULL; } + +/* Takes a string, truncates it where it's safe, returns the new length */ +int truncate_utf8( char *string, int maxlen ) +{ + char *end; + g_utf8_validate( (const gchar *) string, maxlen, (const gchar **) &end ); + *end = '\0'; + return end - string; +} diff --git a/lib/misc.h b/lib/misc.h index d8cce32b..bf587332 100644 --- a/lib/misc.h +++ b/lib/misc.h @@ -149,5 +149,6 @@ G_MODULE_EXPORT gboolean ssl_sockerr_again( void *ssl ); G_MODULE_EXPORT int md5_verify_password( char *password, char *hash ); G_MODULE_EXPORT char **split_command_parts( char *command, int limit ); G_MODULE_EXPORT char *get_rfc822_header( const char *text, const char *header, int len ); +G_MODULE_EXPORT int truncate_utf8( char *string, int maxlen ); #endif -- cgit v1.2.3