[PATCH] fix segfault on nntp server connect failure
Cal Peake <[email protected]> Fri, 1 Feb 2013 10:59:17 -0500 (EST)
| Newsgroups | gmane.comp.gnome.apps.pan.devel |
|---|---|
| Message-ID | <alpine.LNX.2.00.1302011040570.4305@lancer.cnet.absolutedigital.net> |
Hi,
Attached (and below) is a cut-n-paste job from
pan/tasks/socket-impl-openssl.cc to pan/tasks/socket-impl-gio.cc that
fixes a segfault that occurs if we're unable to establish a connection to
a configured news server.
Technical details: A failure to connect in the function create_channel()
leaves a GIOChannel pointer uninitialized that then gets passed to
g_io_channel_{unix,win32}_get_fd().
Kind regards,
--
Cal Peake
diff --git a/pan/tasks/socket-impl-gio.cc b/pan/tasks/socket-impl-gio.cc
index b11e926..afeb1a3 100644
--- a/pan/tasks/socket-impl-gio.cc
+++ b/pan/tasks/socket-impl-gio.cc
@@ -286,11 +286,14 @@ GIOChannelSocket :: open (const StringView& address, int port, std::string& setm
{
_host.assign (address.str, address.len);
_channel = create_channel (address, port, setme_err);
+ if (_channel)
+ {
#ifdef G_OS_WIN32
_id = g_io_channel_win32_get_fd(_channel);
#else
_id = g_io_channel_unix_get_fd(_channel);
#endif // G_OS_WIN32
+ }
return _channel != 0;
}
_______________________________________________
Pan-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/pan-devel
fix-gio-socket-segfault.diff
(text/plain, 596 B)
diff --git a/pan/tasks/socket-impl-gio.cc b/pan/tasks/socket-impl-gio.cc
index b11e926..afeb1a3 100644
--- a/pan/tasks/socket-impl-gio.cc
+++ b/pan/tasks/socket-impl-gio.cc
@@ -286,11 +286,14 @@ GIOChannelSocket :: open (const StringView& address, int port, std::string& setm
{
_host.assign (address.str, address.len);
_channel = create_channel (address, port, setme_err);
+ if (_channel)
+ {
#ifdef G_OS_WIN32
_id = g_io_channel_win32_get_fd(_channel);
#else
_id = g_io_channel_unix_get_fd(_channel);
#endif // G_OS_WIN32
+ }
return _channel != 0;
}