util:charset: Return EILSEQ in smb_iconv() if newer libc is detected
[mat/samba.git] / lib / util / charset / iconv.c
index bf561f26619d9764213dbf705e69942f9f996d23..e06fa2ca3962829f3e9139d4acaa6477175d5f6b 100644 (file)
@@ -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;
                }