summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2014-06-05 08:57:40 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2014-06-05 08:57:40 -0700
commitc41287b318da8849ea61cf712a303f0a84da56dd (patch)
treeaa974bdc5981a827fa691fd7de7ed17bc22454d7
parent92f62fed0054cc8797cd2f1904c556b80d589cf7 (diff)
downloadzsh-c41287b318da8849ea61cf712a303f0a84da56dd.tar.gz
zsh-c41287b318da8849ea61cf712a303f0a84da56dd.zip
32716: properly test iconv return values for error conditions
-rw-r--r--ChangeLog5
-rw-r--r--Src/utils.c7
2 files changed, 8 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index adc98a6a1..ab953e675 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-06-05 Barton E. Schaefer <schaefer@zsh.org>
+
+ * 32716 (via Jun T. 31714): Src/utils.c: properly test iconv
+ return values for error conditions
+
2014-06-04 Barton E. Schaefer <schaefer@zsh.org>
* 32711: Test/A07control.ztst: run "continue" test in a new
diff --git a/Src/utils.c b/Src/utils.c
index 8b512bbd9..59b9435ff 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -4287,7 +4287,7 @@ zreaddir(DIR *dir, int ignoredots)
#if defined(HAVE_ICONV) && defined(__APPLE__)
if (!conv_ds)
conv_ds = iconv_open("UTF-8", "UTF-8-MAC");
- if (conv_ds) {
+ if (conv_ds != (iconv_t)(-1)) {
/* Force initial state in case re-using conv_ds */
(void) iconv(conv_ds, 0, &orig_name_len, 0, &conv_name_len);
@@ -4298,12 +4298,11 @@ zreaddir(DIR *dir, int ignoredots)
conv_name_len = orig_name_len;
if (iconv(conv_ds,
&orig_name_ptr, &orig_name_len,
- &conv_name_ptr, &conv_name_len) >= 0) {
- if (orig_name_len == 0) {
+ &conv_name_ptr, &conv_name_len) != (size_t)(-1) &&
+ orig_name_len == 0) {
/* Completely converted, metafy and return */
*conv_name_ptr = '\0';
return metafy(conv_name, -1, META_STATIC);
- }
}
/* Error, or conversion incomplete, keep the original name */
}