iconv sync 6/x: FreeBSD SVN 279404
authorJohn Marino <draco@marino.st>
Fri, 3 Jul 2015 22:14:00 +0000 (00:14 +0200)
committerJohn Marino <draco@marino.st>
Sat, 4 Jul 2015 08:19:06 +0000 (10:19 +0200)
Avoid lookup of CODESET aliases using unitialized path.  We do not use
iconv.alias file so avoid using the vestiges of the code that do.

lib/libc/citrus/citrus_iconv.c

index 51ea5cb..a609fab 100644 (file)
@@ -278,7 +278,9 @@ _citrus_iconv_open(struct _citrus_iconv * __restrict * __restrict rcv,
        struct _citrus_iconv *cv = NULL;
        struct _citrus_iconv_shared *ci = NULL;
        char realdst[PATH_MAX], realsrc[PATH_MAX];
+#ifdef _PATH_ICONV
        char buf[PATH_MAX], path[PATH_MAX];
+#endif
        int ret;
 
        init_cache();
@@ -290,10 +292,16 @@ _citrus_iconv_open(struct _citrus_iconv * __restrict * __restrict rcv,
                dst = nl_langinfo(CODESET);
 
        /* resolve codeset name aliases */
+#ifdef _PATH_ICONV
+       snprintf(path, sizeof(path), "%s/%s", _PATH_ICONV, _CITRUS_ICONV_ALIAS);
        strlcpy(realsrc, _lookup_alias(path, src, buf, (size_t)PATH_MAX,
            _LOOKUP_CASE_IGNORE), (size_t)PATH_MAX);
        strlcpy(realdst, _lookup_alias(path, dst, buf, (size_t)PATH_MAX,
            _LOOKUP_CASE_IGNORE), (size_t)PATH_MAX);
+#else
+       strlcpy(realsrc, src, (size_t)PATH_MAX);
+       strlcpy(realdst, dst, (size_t)PATH_MAX);
+#endif
 
        /* sanity check */
        if (strchr(realsrc, '/') != NULL || strchr(realdst, '/'))