diff options
-rw-r--r-- | bitlbee.h | 2 | ||||
-rw-r--r-- | irc_im.c | 4 | ||||
-rw-r--r-- | irc_send.c | 3 | ||||
-rw-r--r-- | lib/events_glib.c | 8 | ||||
-rw-r--r-- | lib/oauth2.c | 10 | ||||
-rw-r--r-- | protocols/jabber/jabber.c | 2 | ||||
-rw-r--r-- | protocols/msn/gw.c | 15 | ||||
-rw-r--r-- | protocols/msn/ns.c | 7 | ||||
-rw-r--r-- | protocols/oscar/ssi.c | 2 | ||||
-rw-r--r-- | protocols/twitter/twitter.c | 15 | ||||
-rw-r--r-- | protocols/yahoo/yahoo2.h | 2 | ||||
-rw-r--r-- | unix.c | 20 |
12 files changed, 56 insertions, 34 deletions
@@ -92,8 +92,6 @@ extern "C" { #define g_io_add_watch_full __PLEASE_USE_B_INPUT_ADD__ #undef g_source_remove #define g_source_remove __PLEASE_USE_B_EVENT_REMOVE__ -#undef g_source_remove_by_user_data -#define g_source_remove_by_user_data __PLEASE_USE_B_SOURCE_REMOVE_BY_USER_DATA__ #undef g_main_run #define g_main_run __PLEASE_USE_B_MAIN_RUN__ #undef g_main_quit @@ -49,7 +49,7 @@ static gboolean bee_irc_user_new(bee_t *bee, bee_user_t *bu) char nick[MAX_NICK_LENGTH + 1], *s; memset(nick, 0, MAX_NICK_LENGTH + 1); - strcpy(nick, nick_get(bu)); + strncpy(nick, nick_get(bu), MAX_NICK_LENGTH); bu->ui_data = iu = irc_user_new(irc, nick); iu->bu = bu; @@ -722,6 +722,8 @@ static gboolean bee_irc_chat_invite(bee_t *bee, bee_user_t *bu, const char *name if (irc_channel_by_name(irc, s) == NULL) { g_free(channel); channel = s; + } else { + g_free(s); } } @@ -174,11 +174,10 @@ void irc_send_join(irc_channel_t *ic, irc_user_t *iu) irc_write(irc, ":%s!%s@%s JOIN :%s", iu->nick, iu->user, iu->host, ic->name); if (iu == irc->user) { - irc_write(irc, ":%s MODE %s +%s", irc->root->host, ic->name, ic->mode); - irc_send_names(ic); if (ic->topic && *ic->topic) { irc_send_topic(ic, FALSE); } + irc_send_names(ic); } } diff --git a/lib/events_glib.c b/lib/events_glib.c index 404031e8..dca704e1 100644 --- a/lib/events_glib.c +++ b/lib/events_glib.c @@ -81,7 +81,7 @@ static gboolean gaim_io_invoke(GIOChannel *source, GIOCondition condition, gpoin gaim_cond |= B_EV_IO_WRITE; } - event_debug("gaim_io_invoke( %d, %d, 0x%x )\n", g_io_channel_unix_get_fd(source), condition, data); + event_debug("gaim_io_invoke( %d, %d, %p )\n", g_io_channel_unix_get_fd(source), condition, data); st = closure->function(closure->data, g_io_channel_unix_get_fd(source), gaim_cond); @@ -100,7 +100,7 @@ static gboolean gaim_io_invoke(GIOChannel *source, GIOCondition condition, gpoin static void gaim_io_destroy(gpointer data) { - event_debug("gaim_io_destroy( 0x%x )\n", data); + event_debug("gaim_io_destroy( 0%p )\n", data); g_free(data); } @@ -126,7 +126,7 @@ gint b_input_add(gint source, b_input_condition condition, b_event_handler funct st = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, gaim_io_invoke, closure, gaim_io_destroy); - event_debug("b_input_add( %d, %d, 0x%x, 0x%x ) = %d (%p)\n", source, condition, function, data, st, closure); + event_debug("b_input_add( %d, %d, %p, %p ) = %d (%p)\n", source, condition, function, data, st, closure); g_io_channel_unref(channel); return st; @@ -139,7 +139,7 @@ gint b_timeout_add(gint timeout, b_event_handler func, gpointer data) for now, BitlBee only looks at the "data" argument. */ gint st = g_timeout_add(timeout, (GSourceFunc) func, data); - event_debug("b_timeout_add( %d, %d, %d ) = %d\n", timeout, func, data, st); + event_debug("b_timeout_add( %d, %p, %p ) = %d\n", timeout, func, data, st); return st; } diff --git a/lib/oauth2.c b/lib/oauth2.c index d6cf9a53..f9acd6c8 100644 --- a/lib/oauth2.c +++ b/lib/oauth2.c @@ -139,9 +139,15 @@ static void oauth2_access_token_done(struct http_request *req) { struct oauth2_access_token_data *cb_data = req->data; char *atoken = NULL, *rtoken = NULL, *error = NULL; - char *content_type; + char *content_type = NULL; - if (getenv("BITLBEE_DEBUG") && req->reply_body) { + if (req->status_code <= 0 && !req->reply_body) { + cb_data->func(cb_data->data, NULL, NULL, req->status_string); + g_free(cb_data); + return; + } + + if (getenv("BITLBEE_DEBUG")) { printf("%s\n", req->reply_body); } diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index 2db026cd..04db365e 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -427,7 +427,7 @@ static void jabber_get_info(struct im_connection *ic, char *who) bud = bud->next; } - jabber_get_vcard(ic, bud ? bud->full_jid : who); + jabber_get_vcard(ic, who); } static void jabber_set_away(struct im_connection *ic, char *state_txt, char *message) diff --git a/protocols/msn/gw.c b/protocols/msn/gw.c index 60514139..5f285f8d 100644 --- a/protocols/msn/gw.c +++ b/protocols/msn/gw.c @@ -86,16 +86,16 @@ void msn_gw_callback(struct http_request *req) gw->waiting = FALSE; gw->polling = FALSE; + if (req->status_code != 200 || !req->reply_body) { + gw->callback(gw->md, -1, B_EV_IO_READ); + return; + } + if (getenv("BITLBEE_DEBUG")) { fprintf(stderr, "\n\x1b[90mHTTP:%s\n", req->reply_body); fprintf(stderr, "\n\x1b[97m\n"); } - if (req->status_code != 200) { - gw->callback(gw->md, -1, B_EV_IO_READ); - return; - } - if ((value = get_rfc822_header(req->reply_headers, "X-MSN-Messenger", 0))) { if (!msn_gw_parse_session_header(gw, value)) { gw->callback(gw->md, -1, B_EV_IO_READ); @@ -112,7 +112,10 @@ void msn_gw_callback(struct http_request *req) if (req->body_size) { g_byte_array_append(gw->in, (const guint8 *) req->reply_body, req->body_size); - gw->callback(gw->md, -1, B_EV_IO_READ); + + if (!gw->callback(gw->md, -1, B_EV_IO_READ)) { + return; + } } if (gw->poll_timeout != -1) { diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 0011d7e7..0aab149d 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -180,6 +180,7 @@ static gboolean msn_ns_callback(gpointer data, gint source, b_input_condition co if (st <= 0) { imcb_error(ic, "Error while reading from server"); imc_logout(ic, TRUE); + g_free(bytes); return FALSE; } @@ -187,11 +188,7 @@ static gboolean msn_ns_callback(gpointer data, gint source, b_input_condition co g_free(bytes); - /* Ignore ret == 0, it's already disconnected then. */ - msn_handler(md); - - return TRUE; - + return msn_handler(md); } int msn_ns_command(struct msn_data *md, char **cmd, int num_parts) diff --git a/protocols/oscar/ssi.c b/protocols/oscar/ssi.c index 7583114f..d055185e 100644 --- a/protocols/oscar/ssi.c +++ b/protocols/oscar/ssi.c @@ -65,7 +65,7 @@ static struct aim_ssi_item *aim_ssi_itemlist_add(struct aim_ssi_item **list, str do { newitem->gid += 0x0001; for (cur = *list, i = 0; ((cur) && (!i)); cur = cur->next) { - if ((cur->gid == newitem->gid) && (cur->gid == newitem->gid)) { + if ((cur->bid == newitem->bid) && (cur->gid == newitem->gid)) { i = 1; } } diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index 421a0552..4debc08a 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -482,17 +482,24 @@ int twitter_url_len_diff(gchar *msg, unsigned int target_len) return url_len_diff; } -static gboolean twitter_length_check(struct im_connection *ic, gchar * msg) +int twitter_message_len(gchar *msg, int target_len) { - int max = set_getint(&ic->acc->set, "message_length"), len; - int target_len = set_getint(&ic->acc->set, "target_url_length"); int url_len_diff = 0; if (target_len > 0) { url_len_diff = twitter_url_len_diff(msg, target_len); } - if (max == 0 || (len = g_utf8_strlen(msg, -1) + url_len_diff) <= max) { + return g_utf8_strlen(msg, -1) + url_len_diff; +} + +static gboolean twitter_length_check(struct im_connection *ic, gchar * msg) +{ + int max = set_getint(&ic->acc->set, "message_length"); + int target_len = set_getint(&ic->acc->set, "target_url_length"); + int len = twitter_message_len(msg, target_len); + + if (max == 0 || len <= max) { return TRUE; } diff --git a/protocols/yahoo/yahoo2.h b/protocols/yahoo/yahoo2.h index 464672a1..b9d0e176 100644 --- a/protocols/yahoo/yahoo2.h +++ b/protocols/yahoo/yahoo2.h @@ -32,8 +32,6 @@ extern "C" { #define free(x) g_free(x) #undef malloc #define malloc(x) g_malloc(x) -#undef calloc -#define calloc(x, y) g_calloc(x, y) #undef realloc #define realloc(x, y) g_realloc(x, y) #undef strdup @@ -211,15 +211,25 @@ static int crypt_main(int argc, char *argv[]) " %s -x chkhash <hashed password> <cleartext password>\n", argv[0], argv[0], argv[0], argv[0], argv[0]); } else if (strcmp(argv[2], "enc") == 0) { - pass_len = arc_encode(argv[4], strlen(argv[4]), (unsigned char **) &pass_cr, argv[3], 12); - printf("%s\n", base64_encode(pass_cr, pass_len)); + char *encoded; + + pass_len = arc_encode(argv[4], strlen(argv[4]), &pass_cr, argv[3], 12); + + encoded = base64_encode(pass_cr, pass_len); + printf("%s\n", encoded); + g_free(encoded); + g_free(pass_cr); } else if (strcmp(argv[2], "dec") == 0) { - pass_len = base64_decode(argv[4], (unsigned char **) &pass_cr); + pass_len = base64_decode(argv[4], &pass_cr); arc_decode(pass_cr, pass_len, (char **) &pass_cl, argv[3]); printf("%s\n", pass_cl); + + g_free(pass_cr); + g_free(pass_cl); } else if (strcmp(argv[2], "hash") == 0) { md5_byte_t pass_md5[21]; md5_state_t md5_state; + char *encoded; random_bytes(pass_md5 + 16, 5); md5_init(&md5_state); @@ -227,7 +237,9 @@ static int crypt_main(int argc, char *argv[]) md5_append(&md5_state, pass_md5 + 16, 5); /* Add the salt. */ md5_finish(&md5_state, pass_md5); - printf("%s\n", base64_encode(pass_md5, 21)); + encoded = base64_encode(pass_md5, 21); + printf("%s\n", encoded); + g_free(encoded); } else if (strcmp(argv[2], "unhash") == 0) { printf("Hash %s submitted to a massive Beowulf cluster of\n" "overclocked 486s. Expect your answer next year somewhere around this time. :-)\n", argv[3]); |