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.
| 8675 | 1 | /* |
| 2 | * nmmessage.h | |
| 3 | * | |
|
8933
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
4 | * Copyright (c) 2004 Novell, Inc. All Rights Reserved. |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
5 | * |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
6 | * This program is free software; you can redistribute it and/or modify |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
7 | * it under the terms of the GNU General Public License as published by |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
8 | * the Free Software Foundation; version 2 of the License. |
| 8675 | 9 | * |
|
8933
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
13 | * GNU General Public License for more details. |
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
14 | * |
|
8933
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
16 | * 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:
15435
diff
changeset
|
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 8675 | 18 | * |
| 19 | */ | |
| 20 | ||
| 21 | #ifndef __NM_MESSAGE_H__ | |
| 22 | #define __NM_MESSAGE_H__ | |
| 23 | ||
| 24 | typedef struct _NMMessage NMMessage; | |
| 25 | ||
| 26 | #include "nmconference.h" | |
| 27 | ||
| 28 | /** | |
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
29 | * Creates a new message. |
| 8675 | 30 | * |
| 31 | * The returned message should be released by calling | |
| 32 | * nm_release_message | |
| 33 | * | |
| 34 | * @param text The message text | |
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
35 | * @return A newly allocated message |
| 8675 | 36 | */ |
| 37 | NMMessage *nm_create_message(const char *text); | |
| 38 | ||
| 39 | /** | |
|
8933
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
40 | * Increment the reference count for the message object. |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
41 | * |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
42 | * @param msg The message |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
43 | */ |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
44 | void nm_message_add_ref(NMMessage * msg); |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
45 | |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
46 | /** |
| 8675 | 47 | * Releases a message. |
| 48 | * | |
| 49 | * @param msg The message | |
| 50 | */ | |
| 51 | void nm_release_message(NMMessage * msg); | |
| 52 | ||
| 53 | /** | |
| 54 | * Returns the message text | |
| 55 | * | |
| 56 | * @param msg The message | |
| 57 | * @return The message text | |
| 58 | */ | |
| 59 | const char *nm_message_get_text(NMMessage * msg); | |
| 60 | ||
| 61 | /** | |
| 62 | * Sets the conference object for a message | |
| 63 | * | |
| 64 | * @param msg The message | |
| 65 | * @param conf The conference to associate with the message | |
| 66 | * @return RVALUE_OK on success | |
| 67 | */ | |
| 68 | void nm_message_set_conference(NMMessage * msg, NMConference * conf); | |
| 69 | ||
| 70 | /** | |
| 71 | * Returns the conference object associated with the message | |
| 72 | * | |
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
73 | * Note: this does not increment the reference count for the |
|
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
74 | * conference and the conference should NOT be released with |
| 8675 | 75 | * nm_release_conference. If the reference needs to be kept |
| 76 | * around nm_conference_add_ref should be called. | |
| 77 | * | |
| 78 | * @param msg The message | |
| 79 | * @return The conference associated with this message | |
| 80 | */ | |
| 81 | NMConference *nm_message_get_conference(NMMessage * msg); | |
| 82 | ||
| 83 | #endif |