diff --git a/hexchat-Avoid-direct-use-of-libproxy.patch b/hexchat-Avoid-direct-use-of-libproxy.patch new file mode 100644 index 0000000..0957f30 --- /dev/null +++ b/hexchat-Avoid-direct-use-of-libproxy.patch @@ -0,0 +1,199 @@ +From 54321bae1feaf0845d75f67245c95795651277f5 Mon Sep 17 00:00:00 2001 +From: Michael Catanzaro +Date: Mon, 12 Jul 2021 08:38:02 -0500 +Subject: [PATCH] Avoid direct use of libproxy + +Since hexchat already depends on GLib, it's better to use GProxyResolver +instead. This might use libproxy, or not, as appropriate. + +P.S. This removes a memory safety issue because proxy_list is allocated +using malloc(), not g_malloc(), and therefore using g_strfreev() is +incorrect. The proper way to free the proxy list returned by libproxy +is to use px_proxy_factory_free_proxies() (but nobody does that because +it was added in libproxy 0.4.16, which is somewhat recent). +--- + meson.build | 1 - + meson_options.txt | 3 --- + src/common/hexchat.c | 16 ---------------- + src/common/meson.build | 4 ---- + src/common/server.c | 26 ++++++++++++++++---------- + src/fe-gtk/setup.c | 2 -- + 6 files changed, 16 insertions(+), 36 deletions(-) + +diff --git a/meson.build b/meson.build +index 18baf26e126e..381e3fd87ac6 100644 +--- a/meson.build ++++ b/meson.build +@@ -33,7 +33,6 @@ config_h.set10('ENABLE_NLS', true) + + # Optional features + config_h.set('USE_OPENSSL', get_option('with-ssl')) +-config_h.set('USE_LIBPROXY', get_option('with-libproxy')) + config_h.set('USE_LIBCANBERRA', get_option('with-libcanberra')) + config_h.set('USE_DBUS', get_option('with-dbus')) + config_h.set('USE_PLUGIN', get_option('with-plugin')) +diff --git a/meson_options.txt b/meson_options.txt +index 100a5ee72ad7..ad03d6bc58ef 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -13,9 +13,6 @@ option('with-plugin', type: 'boolean', + option('with-dbus', type: 'boolean', + description: 'Support used for single-instance and scripting interface, Unix only' + ) +-option('with-libproxy', type: 'boolean', +- description: 'Support for getting proxy information, Unix only' +-) + option('with-libnotify', type: 'boolean', + description: 'Support for freedesktop notifications, Unix only' + ) +diff --git a/src/common/hexchat.c b/src/common/hexchat.c +index e9a9a7fc9fcd..a98fcafba2f7 100644 +--- a/src/common/hexchat.c ++++ b/src/common/hexchat.c +@@ -57,10 +57,6 @@ + #include /* for g_type_init() */ + #endif + +-#ifdef USE_LIBPROXY +-#include +-#endif +- + GSList *popup_list = 0; + GSList *button_list = 0; + GSList *dlgbutton_list = 0; +@@ -111,10 +107,6 @@ struct session *current_tab; + struct session *current_sess = 0; + struct hexchatprefs prefs; + +-#ifdef USE_LIBPROXY +-pxProxyFactory *libproxy_factory; +-#endif +- + /* + * Update the priority queue of the "interesting sessions" + * (sess_list_by_lastact). +@@ -1101,10 +1093,6 @@ main (int argc, char *argv[]) + hexchat_remote (); + #endif + +-#ifdef USE_LIBPROXY +- libproxy_factory = px_proxy_factory_new (); +-#endif +- + #ifdef WIN32 + coinit_result = CoInitializeEx (NULL, COINIT_APARTMENTTHREADED); + if (SUCCEEDED (coinit_result)) +@@ -1147,10 +1135,6 @@ main (int argc, char *argv[]) + } + #endif + +-#ifdef USE_LIBPROXY +- px_proxy_factory_free (libproxy_factory); +-#endif +- + #ifdef WIN32 + WSACleanup (); + #endif +diff --git a/src/common/meson.build b/src/common/meson.build +index bbb646459522..5885ec9e47c1 100644 +--- a/src/common/meson.build ++++ b/src/common/meson.build +@@ -77,10 +77,6 @@ if get_option('with-ssl') + common_deps += libssl_dep + endif + +-if get_option('with-libproxy') +- common_deps += dependency('libproxy-1.0') +-endif +- + if get_option('with-libcanberra') + common_deps += dependency('libcanberra', version: '>= 0.22') + endif +diff --git a/src/common/server.c b/src/common/server.c +index 3db0a9635fc5..a96e81f43d15 100644 +--- a/src/common/server.c ++++ b/src/common/server.c +@@ -61,10 +61,6 @@ + #include "ssl.h" + #endif + +-#ifdef USE_LIBPROXY +-#include +-#endif +- + #ifdef USE_OPENSSL + /* local variables */ + static struct session *g_sess = NULL; +@@ -78,9 +74,15 @@ static void server_disconnect (session * sess, int sendquit, int err); + static int server_cleanup (server * serv); + static void server_connect (server *serv, char *hostname, int port, int no_login); + +-#ifdef USE_LIBPROXY +-extern pxProxyFactory *libproxy_factory; +-#endif ++static void ++write_error (char *message, GError **error) ++{ ++ if (error == NULL || *error == NULL) { ++ return; ++ } ++ g_printerr ("%s: %s\n", message, (*error)->message); ++ g_clear_error (error); ++} + + /* actually send to the socket. This might do a character translation or + send via SSL. server/dcc both use this function. */ +@@ -1365,14 +1367,16 @@ server_child (server * serv) + + if (!serv->dont_use_proxy) /* blocked in serverlist? */ + { +-#ifdef USE_LIBPROXY + if (prefs.hex_net_proxy_type == 5) + { + char **proxy_list; + char *url, *proxy; ++ GProxyResolver *resolver; ++ GError *error = NULL; + ++ resolver = g_proxy_resolver_get_default (); + url = g_strdup_printf ("irc://%s:%d", hostname, port); +- proxy_list = px_proxy_factory_get_proxies (libproxy_factory, url); ++ proxy_list = g_proxy_resolver_lookup (resolver, url, NULL, &error); + + if (proxy_list) { + /* can use only one */ +@@ -1385,6 +1389,8 @@ server_child (server * serv) + proxy_type = 3; + else if (!strncmp (proxy, "socks", 5)) + proxy_type = 2; ++ } else { ++ write_error ("Failed to lookup proxy", &error); + } + + if (proxy_type) { +@@ -1399,7 +1405,7 @@ server_child (server * serv) + g_strfreev (proxy_list); + g_free (url); + } +-#endif ++ + if (prefs.hex_net_proxy_host[0] && + prefs.hex_net_proxy_type > 0 && + prefs.hex_net_proxy_use != 2) /* proxy is NOT dcc-only */ +diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c +index 3d003eefc776..a7e3a15cac52 100644 +--- a/src/fe-gtk/setup.c ++++ b/src/fe-gtk/setup.c +@@ -614,9 +614,7 @@ static const char *const proxytypes[] = + N_("SOCKS4"), + N_("SOCKS5"), + N_("HTTP"), +-#ifdef USE_LIBPROXY + N_("Auto"), +-#endif + NULL + }; + +-- +2.31.1 + diff --git a/hexchat.spec b/hexchat.spec index 7dc7bfd..f910946 100644 --- a/hexchat.spec +++ b/hexchat.spec @@ -3,7 +3,7 @@ Summary: A popular and easy to use graphical IRC (chat) client Name: hexchat Version: 2.14.3 -Release: 14%{?dist} +Release: 15%{?dist} License: GPLv2+ URL: https://hexchat.github.io Source: https://dl.hexchat.net/hexchat/%{name}-%{version}.tar.xz @@ -14,6 +14,10 @@ Patch2: python-plugin-from-master.patch Patch3: https://github.com/hexchat/hexchat/commit/163608d7fd861c2c4911a38f45be484c88626bdc.patch Patch4: https://github.com/hexchat/hexchat/commit/090fd29acf4af0d8e13fcf2861b14a356db72641.patch +# https://github.com/hexchat/hexchat/pull/2609 +# https://bugzilla.redhat.com/show_bug.cgi?id=1981509 +Patch5: hexchat-Avoid-direct-use-of-libproxy.patch + BuildRequires: gcc BuildRequires: meson BuildRequires: hicolor-icon-theme @@ -22,7 +26,6 @@ BuildRequires: pkgconfig(gtk+-2.0) BuildRequires: pkgconfig(dbus-glib-1) BuildRequires: pkgconfig(libcanberra) BuildRequires: pkgconfig(libnotify) -BuildRequires: pkgconfig(libproxy-1.0) BuildRequires: pkgconfig(iso-codes) BuildRequires: pkgconfig(openssl) BuildRequires: pkgconfig(python3) @@ -81,6 +84,10 @@ This package contains the development files for %{name}. %{_libdir}/pkgconfig/hexchat-plugin.pc %changelog +* Mon Jul 12 2021 Debarshi Ray - 2.14.3-15 +- Avoid direct use of libproxy +Resolves: #1981509 + * Wed Jun 16 2021 Mohan Boddu - 2.14.3-14 - Rebuilt for RHEL 9 BETA for openssl 3.0 Related: rhbz#1971065