/bin/ls formatting broken for non-C(?) locales

Andrey Chernov ache at freebsd.org
Wed Nov 25 15:31:21 UTC 2015


On 25.11.2015 18:12, Andrey Chernov wrote:
> On 25.11.2015 17:35, Baptiste Daroussin wrote:
>>> BTW, array size looks suspicious:
>>> static wchar_t wab_months[12][MAX_ABMON_WIDTH * 2 * MB_LEN_MAX];
>>> what MB_LEN_MAX doing here? This constant is for multiple-bytes encoded,
>>> not for wide chars.
>> Bad copy/paste sorry it should be "MAX_ABMON_WIDTH * 2"
> 
> I don't check deep enough, it seems first array
> MAX_ABMON_WIDTH * MB_LEN_MAX + 1
> and second one
> MAX_ABMON_WIDTH * 2 + 1
> 

No. We can't assume anything here and should integrate limits from the
locale for months fields instead. F.e. in abstract general case in wide
array can be 100 zero-width characters + 5 of normal characters, so
width-oriented sizes not prevents overflowing.

First array size should be from locale internals,
second one == first * sizeof(wchar_t)
it will be safe for not overflowing.

-- 
http://ache.vniz.net/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-current/attachments/20151125/eec9f4bb/attachment.bin>


More information about the freebsd-current mailing list