aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/misc.c9
-rw-r--r--lib/misc.h1
-rw-r--r--lib/ns_parse.c2
-rw-r--r--lib/proxy.c14
4 files changed, 19 insertions, 7 deletions
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
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..2e0dc2cf 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);
@@ -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 {
@@ -173,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)
{
@@ -213,7 +215,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 +310,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 +502,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);