Bug 209907 - _ascii_wcsnrtombs neglects to set src on EILSEQ error
Summary: _ascii_wcsnrtombs neglects to set src on EILSEQ error
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: standards (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Andrey A. Chernov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-31 17:09 UTC by Roel Standaert
Modified: 2016-06-03 07:38 UTC (History)
1 user (show)

See Also:
ache: mfc-stable10+


Attachments
Test program that reproduces the issue (312 bytes, text/x-csrc)
2016-05-31 17:09 UTC, Roel Standaert
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roel Standaert 2016-05-31 17:09:04 UTC
Created attachment 170884 [details]
Test program that reproduces the issue

I noticed that when using wcsrtombs, if a character is encountered that can not be converted, it sets errno to EILSEQ and returns (size_t)-1. However *src still points to the original character, even though it should point to the character after the one that conversion stopped at. I've attached a test program that reproduces the issue.

The expected output is:
inptr - in: 7

The actual output is:
inptr - in: 0

The culprit appears to be in _ascii_wcsnrtombs, line 181 in lib/libc/locale/ascii.c: it's missing a "*src = s;" statement before the return.
Comment 1 commit-hook freebsd_committer freebsd_triage 2016-05-31 18:45:15 UTC
A commit references this bug:

Author: ache
Date: Tue May 31 18:44:34 UTC 2016
New revision: 301069
URL: https://svnweb.freebsd.org/changeset/base/301069

Log:
  For EILSEQ case in mbsnrtowcs() and wcsnrtombs() update src to point to
  the character after the one this conversion stopped at.

  PR:     209907
  Submitted by: Roel Standaert <roel@abittechnical.com> (partially)
  MFC after:      3 days

Changes:
  head/lib/libc/locale/ascii.c
  head/lib/libc/locale/none.c
Comment 2 commit-hook freebsd_committer freebsd_triage 2016-06-03 07:35:10 UTC
A commit references this bug:

Author: ache
Date: Fri Jun  3 07:35:00 UTC 2016
New revision: 301245
URL: https://svnweb.freebsd.org/changeset/base/301245

Log:
  For EILSEQ case in mbsnrtowcs() and wcsnrtombs() update src to point to
  the character after the one this conversion stopped at.

  PR:     209907
  Submitted by:   Roel Standaert <roel@abittechnical.com> (partially)

Changes:
_U  stable/10/
  stable/10/lib/libc/locale/ascii.c
  stable/10/lib/libc/locale/none.c