CVSROOT:        /cvs
Module name:    src
Changes by:     schwa...@cvs.openbsd.org        2016/02/27 07:02:13

Modified files:
        lib/libc/locale: mbtowc.c 

Log message:
If an incomplete character is passed to mbtowc(3), set errno to EILSEQ.
This is unambiguously required both by POSIX and by our own manual page.

It also makes a lot of sense because having a function that can
fail and that sets errno in some failure modes but does not set
errno in other failure modes would be a terrible idea.  Such a
function would be ridiculously complicated to use.  To detect the
reason for failure, you would have to:

- save errno
- reset errno to zero
- call the function
- inspect the return value to detect failure
- inspect errno to decide about the reason for failure
- if errno is zero, restore the saved errno

That is completely unreasonable, in particular for a seemingly innocous
function like mbtowc(3).  Next to no programmer would get that right in
any real-world program.

Note that this bug is very widespread, it also affects NetBSD,
FreeBSD, Solaris 11, and glibc.  I will also send a note around to
the other systems.

There may be fallout from programs using the interface incorrectly.
If you run into any, please report that to me.

OK millert@

Reply via email to