mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-23 09:43:32 +08:00
locale: Fix signed char bug in lr_getc
The array lr->buf contains characters, which can be signed. A 0xff byte in the input could be incorrectly reported as EOF. More importantly, get_string in linereader.c converts a signed input byte to a Unicode code point using ADDWC ((uint32_t) ch), under the assumption that this decodes the ISO-8859-1 input encoding. If char is signed, this does not give the correct result. This means that ISO-8859-1 input files for localedef are not actually supported, contrary to the comment in get_string. This is a happy accident because we can therefore change the file encoding to UTF-8 without impacting backwards compatibility. While at it, remove the \32 check for MS-DOS end-of-file character (^Z). Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
parent
5dcbff5879
commit
19d4944459
@ -134,7 +134,7 @@ lr_getc (struct linereader *lr)
|
||||
return EOF;
|
||||
}
|
||||
|
||||
return lr->buf[lr->idx] == '\32' ? EOF : lr->buf[lr->idx++];
|
||||
return lr->buf[lr->idx++] & 0xff;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user