Project

General

Profile

Actions

Submit #2920

closed

_ascii_wcsnrtombs, _ascii_mbsnrtowcs, and _none_wcsnrtombs neglect to set src on EILSEQ error

Added by RockinRoel almost 8 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Target version:
-
Start date:
06/08/2016
Due date:
% Done:

0%

Estimated time:

Description

DragonFlyBSD's libc also suffers from this bug in FreeBSD and Mac OS X: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209907

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

I've included the patch that fixes it for the none and ascii locale (it's fine for other locales).


Files

test_wcsrtombs.c (312 Bytes) test_wcsrtombs.c Test program that reproduces the issue RockinRoel, 06/08/2016 04:00 AM
eilseq_fix.patch (1006 Bytes) eilseq_fix.patch Patch RockinRoel, 06/08/2016 04:06 AM
eilseq_fix_corrected_2.patch (1.32 KB) eilseq_fix_corrected_2.patch Fix possible NULL pointer dereference and EILSEQ behavior yellowrabbit2010, 06/09/2016 03:00 AM
Actions #1

Updated by yellowrabbit2010 almost 8 years ago

corrected patch from RockinRoel and, while we are here fix possible NULL pointer dereference.

Actions #2

Updated by dragonflybsd1 almost 8 years ago

  • Assignee set to dragonflybsd1
Actions #4

Updated by liweitianux over 4 years ago

The patch has been committed in 2016.

Actions #5

Updated by liweitianux over 4 years ago

  • Status changed from New to Closed
Actions

Also available in: Atom PDF