Hi.

Recently I discovered a mistake in wget's source, while browsing is.
in iri.c function locale_to_utf8() wrongly checked the return code
of the iconv_open() call [1]. There was "!=" instead of "==".

The patch is attached.

Anyway while trying to reproduce the issue, I realized that the function
is not used in wget at all. It was introduced in 2008 as part of initial
IDN support, but then replaced by remote_to_utf8(). So possibly it can
be completely removed, or the IDN code is not using it by mistake. I didn't
investigate the issue further.

[1] 
http://www.gnu.org/savannah-checkouts/gnu/libiconv/documentation/libiconv-1.13/iconv_open.3.html

Regards,
-- 
Tomas Hozza
Software Engineer - EMEA ENG Developer Experience

PGP: 1D9F3C2D
Red Hat Inc.                               http://cz.redhat.com
From d0c8fbf0da5e126dea0f719bacb8a9705ac18d1f Mon Sep 17 00:00:00 2001
From: Tomas Hozza <[email protected]>
Date: Mon, 7 Jul 2014 22:15:59 +0200
Subject: [PATCH] Fix checking of iconv_open return code.

Based on libiconv documentation, the iconv_open function returns
(iconv_t)(-1).

Signed-off-by: Tomas Hozza <[email protected]>
---
 src/ChangeLog | 4 ++++
 src/iri.c     | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index bfeafa5..df446c8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
 2014-07-07  Tomas Hozza  <[email protected]>
 
+	* irr.c (locale_to_utf8): Fix checking of iconv_open return code
+
+2014-07-07  Tomas Hozza  <[email protected]>
+
 	* openssl.c: Add definition of OPENSSL_CIPHERS_LIST
 	* openssl.c (ssl_init): Use the predefined OPENSSL_CIPHERS_LIST
 
diff --git a/src/iri.c b/src/iri.c
index 9442e4e..4db426e 100644
--- a/src/iri.c
+++ b/src/iri.c
@@ -129,7 +129,7 @@ locale_to_utf8 (const char *str)
     return str;
 
   l2u = iconv_open ("UTF-8", opt.locale);
-  if (l2u != (iconv_t)(-1))
+  if (l2u == (iconv_t)(-1))
     {
       logprintf (LOG_VERBOSE, _("Conversion from %s to %s isn't supported\n"),
                  quote (opt.locale), quote ("UTF-8"));
-- 
1.9.3

Reply via email to