Bug 176250 - [libc] [patch] euc locale input modifies data
Summary: [libc] [patch] euc locale input modifies data
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 9.1-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Baptiste Daroussin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-18 17:10 UTC by J.R. Oldroyd
Modified: 2018-11-17 00:11 UTC (History)
2 users (show)

See Also:


Attachments
file.diff (428 bytes, patch)
2013-02-18 17:10 UTC, J.R. Oldroyd
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description J.R. Oldroyd 2013-02-18 17:10:00 UTC
When reading an invalid multibyte data sequence while set to an euc locale,
e.g., ja_JP.eucJP, the src/lib/libc/locale/euc.c code will modify the bytes
read to ensure that the 0x8080 or 0x808080 bits are set.  This has the
effect of silently returning data other than that which was in the input.
There is then no way of detecting that the input sequence was invalid.

The correct behavior is to test that those bits are set, return the data
if they are, but return EILSEQ if not.

Fix is applicable to 10-current and 9-stable.  Please MFC.

How-To-Repeat: 1. Create test file containing invalid euc multibyte characters such as:
	0xa440 0xac4f 0xb36f 0xcf20
2. Set locale to, e.g., ja_JP.eucJP.
3. Read characters from file using getwc().  Observe that what's read is:
	0xa4c0 0xaccf 0xb3ef 0xcfa0
Comment 1 David Chisnall freebsd_committer freebsd_triage 2015-10-08 16:29:31 UTC
The change looks fine to me, but I'd like the opinion of someone familiar with the character set in question.
Comment 2 Eitan Adler freebsd_committer freebsd_triage 2018-05-28 19:49:00 UTC
batch change:

For bugs that match the following
-  Status Is In progress 
AND
- Untouched since 2018-01-01.
AND
- Affects Base System OR Documentation

DO:

Reset to open status.


Note:
I did a quick pass but if you are getting this email it might be worthwhile to double check to see if this bug ought to be closed.
Comment 3 Yuri Pankov freebsd_committer freebsd_triage 2018-11-17 00:11:39 UTC
lib/libc/locale/euc.c was revamped in base r286459, and the problem is no longer there.