Mon, 12 Sep 2016 08:55:35 -0500
gg: Protect against issues when closing while connecting
Since the GIOStream is cancelled when data is freed, any cancelled
callbacks are called after such data is freed. This patch guards against
cancelled calls by safely returning without accessing any freed data if
the connection has been cancelled (aka closed).
Futhermore, if GG tries to connect and is quickly disconnected,
ggp_tcpsocket_close() is never called. As far as I can tell, it's an
existing bug, but PurpleSockets both work differently when closing and
are closed by the connection if any leak. So the issue wasn't a major
problem. This patch lessens the issue by guarding against it, but it
should be fixed at some point.
| 9376 | 1 | /** |
| 2 | * @file ycht.h The Yahoo! protocol plugin, YCHT protocol stuff. | |
| 3 | * | |
| 15884 | 4 | * purple |
| 9376 | 5 | * |
| 6 | * Copyright (C) 2004 Timothy Ringenbach <omarvo@hotmail.com> | |
| 7 | * | |
| 15884 | 8 | * Purple is the legal property of its developers, whose names are too numerous |
| 9376 | 9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 10 | * source distribution. | |
| 11 | * | |
| 12 | * This program is free software; you can redistribute it and/or modify | |
| 13 | * it under the terms of the GNU General Public License as published by | |
| 14 | * the Free Software Foundation; either version 2 of the License, or | |
| 15 | * (at your option) any later version. | |
| 16 | * | |
| 17 | * This program is distributed in the hope that it will be useful, | |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 | * GNU General Public License for more details. | |
| 21 | * | |
| 22 | * You should have received a copy of the GNU General Public License | |
| 23 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
15884
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 9376 | 25 | */ |
| 26 | ||
| 15884 | 27 | #ifndef _PURPLE_YCHT_H_ |
| 28 | #define _PURPLE_YCHT_H_ | |
| 9376 | 29 | |
| 30 | /* #define YAHOO_YCHT_DEBUG */ | |
| 31 | ||
| 32 | #define YAHOO_YCHT_HOST "jcs3.chat.dcn.yahoo.com" | |
| 33 | #define YAHOO_YCHT_PORT 8002 | |
| 34 | ||
| 35 | #define YCHT_VERSION (0xae) | |
| 36 | #define YCHT_HEADER_LEN (0x10) | |
| 37 | ||
| 38 | typedef enum { | |
| 39 | YCHT_SERVICE_LOGIN = 0x01, | |
| 40 | YCHT_SERVICE_LOGOUT = 0x02, | |
| 41 | YCHT_SERVICE_CHATJOIN = 0x11, | |
| 42 | YCHT_SERVICE_CHATPART = 0x12, | |
| 43 | YCHT_SERVICE_CHATMSG = 0x41, | |
| 44 | YCHT_SERVICE_CHATMSG_EMOTE = 0x43, | |
| 45 | YCHT_SERVICE_PING = 0x62, | |
|
25105
fe13c190ca13
Remove the commas at the end of enumerator lists. This resolves warnings
Florian Quèze <florian@instantbird.org>
parents:
19859
diff
changeset
|
46 | YCHT_SERVICE_ONLINE_FRIENDS = 0x68 |
| 9376 | 47 | } ycht_service; |
| 48 | /* | |
| 49 | yahoo: YCHT Service: 0x11 Version: 0x100 | |
| 50 | yahoo: Data[0]: Linux, FreeBSD, Solaris:1 | |
| 51 | yahoo: Data[1]: Questions, problems and discussions about all flavors of Unix. | |
| 52 | yahoo: Data[2]: | |
| 53 | yahoo: Data[3]: 0 | |
| 54 | yahoo: Data[4]: sgooki888\0020\002 \0022769036\00258936\002 | |
| 55 | yahoo: --==End of incoming YCHT packet==-- | |
| 56 | ||
| 57 | yahoo: --==Incoming YCHT packet==-- | |
| 58 | yahoo: YCHT Service: 0x12 Version: 0x100 | |
| 59 | yahoo: Data[0]: Linux, FreeBSD, Solaris:1 | |
| 60 | yahoo: Data[1]: cccc4cccc | |
| 61 | yahoo: --==End of incoming YCHT packet==-- | |
| 62 | ||
| 63 | */ | |
| 64 | #define YCHT_SEP "\xc0\x80" | |
| 65 | ||
| 66 | typedef struct _YchtConn { | |
| 15884 | 67 | PurpleConnection *gc; |
| 9376 | 68 | gchar *room; |
| 69 | int room_id; | |
| 70 | gint fd; | |
| 71 | gint inpa; | |
| 72 | gboolean logged_in; | |
| 73 | gboolean changing_rooms; | |
| 74 | guchar *rxqueue; | |
| 75 | guint rxlen; | |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
25105
diff
changeset
|
76 | PurpleCircularBuffer *txbuf; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
11644
diff
changeset
|
77 | guint tx_handler; |
| 9376 | 78 | } YchtConn; |
| 79 | ||
| 80 | typedef struct { | |
| 81 | guint version; | |
| 82 | guint service; | |
| 83 | gint status; | |
| 84 | GList *data; | |
| 85 | } YchtPkt; | |
| 86 | ||
| 15884 | 87 | void ycht_connection_open(PurpleConnection *gc); |
| 9376 | 88 | void ycht_connection_close(YchtConn *ycht); |
| 89 | ||
| 90 | void ycht_chat_join(YchtConn *ycht, const char *room); | |
| 91 | int ycht_chat_send(YchtConn *ycht, const char *room, const char *what); | |
| 92 | void ycht_chat_leave(YchtConn *ycht, const char *room, gboolean logout); | |
| 93 | void ycht_chat_send_invite(YchtConn *ycht, const char *room, const char *buddy, const char *msg); | |
| 94 | void ycht_chat_goto_user(YchtConn *ycht, const char *name); | |
| 95 | void ycht_chat_send_keepalive(YchtConn *ycht); | |
| 96 | ||
| 15884 | 97 | #endif /* _PURPLE_YCHT_H_ */ |