[Bug 296765] iconv(3) ASCII -> ASCII conversion does not recognize invalid bytes

[email protected] Tue, 14 Jul 2026 01:51:14 +0000
Newsgroups gmane.os.freebsd.bugs
Message-ID <[email protected]/bugzilla/>
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296765

            Bug ID: 296765
           Summary: iconv(3) ASCII -> ASCII conversion does not recognize
                    invalid bytes
           Product: Base System
           Version: 14.4-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: [email protected]
          Reporter: [email protected]

The iconv() function is supposed to fail and set errno = EILSEQ if the input
contains a byte sequence that does not describe a valid character of the source
codeset.

This may be a stupid thing to do, but if you convert from ASCII to ASCII,
illegal input bytes (0x80 and up) do not cause an error. When converting from
ASCII to UTF-8, for example, the EILSEQ does happen, so perhaps there is a fast
path in the code that skips the conversion entirely.

There are several aliases for the codeset names, and they can be given as input
to your program, so the obvious solution of "don't do that" when it comes to
the no-op conversion is not as easy as it sounds.

I believe this also affects the behavior of //IGNORE, since bytes that are not
recognized as invalid cannot be ignored.

-- 
You are receiving this mail because:
You are the assignee for the bug.