summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2017-01-30 17:17:38 +0100
committerJeremy Allison <jra@samba.org>2017-02-01 05:16:46 +0100
commit7fd3eb6c04bebd5c8cd25b81198dc0112703497a (patch)
tree46cffb938bb84a81a4aef9fc30bdd8bf62685418 /lib
parent669d2152cb9c1111d36127daee64b4bbfc141b7a (diff)
downloadsamba-7fd3eb6c04bebd5c8cd25b81198dc0112703497a.tar.gz
util:charset: Return EILSEQ in smb_iconv() if newer libc is detected
This is the behaviour of glibc 2.24 and newer. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Wed Feb 1 05:16:46 CET 2017 on sn-devel-144
Diffstat (limited to 'lib')
-rw-r--r--lib/util/charset/iconv.c6
-rw-r--r--lib/util/charset/wscript_configure20
2 files changed, 23 insertions, 3 deletions
diff --git a/lib/util/charset/iconv.c b/lib/util/charset/iconv.c
index bf561f26619..e06fa2ca396 100644
--- a/lib/util/charset/iconv.c
+++ b/lib/util/charset/iconv.c
@@ -740,12 +740,12 @@ static size_t utf8_push(void *cd, const char **inbuf, size_t *inbytesleft,
}
if ((uc[1] & 0xfc) == 0xdc) {
- /* its the second part of a 4 byte sequence. Illegal */
+ errno = EILSEQ;
+#ifndef HAVE_ICONV_ERRNO_ILLEGAL_MULTIBYTE
if (in_left < 4) {
errno = EINVAL;
- } else {
- errno = EILSEQ;
}
+#endif
goto error;
}
diff --git a/lib/util/charset/wscript_configure b/lib/util/charset/wscript_configure
index 804c2663f64..d5ac5d0100f 100644
--- a/lib/util/charset/wscript_configure
+++ b/lib/util/charset/wscript_configure
@@ -16,3 +16,23 @@ if (conf.CHECK_FUNCS_IN('iconv_open', 'iconv', checklibc=False, headers='iconv.h
conf.CHECK_FUNCS('iconv_open', headers='iconv.h')):
conf.DEFINE('HAVE_NATIVE_ICONV', 1)
+
+conf.CHECK_CODE('''
+ uint8_t inbuf[2] = { 0x30, 0xdf };
+ uint8_t outbuf[4] = { 0 };
+ char *ptr_in = (char *)inbuf;
+ char *ptr_out = (char *)outbuf;
+ size_t size_in = sizeof(inbuf);
+ size_t size_out = sizeof(outbuf);
+ size_t ret;
+ iconv_t cd;
+ cd = iconv_open("UTF-8", "UTF-16LE");
+ if (cd == 0 || cd == (iconv_t)-1) return -1;
+ ret = iconv(cd, &ptr_in, &size_in, &ptr_out, &size_out);
+ if (ret != (size_t)-1 || errno != EILSEQ) return -1;
+ ''',
+ define='HAVE_ICONV_ERRNO_ILLEGAL_MULTIBYTE',
+ execute=True,
+ msg='Checking errno of iconv for illegal multibyte sequence',
+ lib='iconv',
+ headers='errno.h iconv.h')