Bug#497525: libc6: fgetws treats C locale wrongly
Package: libc6
Version: 2.3.6.ds1-13etch7
Severity: normal
In the C locale all byte sequences are valid, however using the
following test programme:
#include <stdio.h>
#include <wchar.h>
#include <errno.h>
#include <stdlib.h>
#include <locale.h>
int main() {
size_t buflen = 512;
wchar_t *p = malloc(buflen*sizeof(wchar_t));
setlocale(LC_ALL, "");
fgetws(p, buflen, stdin);
if (ferror(stdin)) {
printf("%s\n", strerror(errno));
return(1);
}
else {
printf("OK\n");
return(0);
}
}
we get:
: ; perl -e 'printf "%c", 0xa1' | env - LC_ALL=C ~/test
Invalid or incomplete multibyte or wide character
0xa1 is of course neither a multibyte or wide character in the C
locale, and fgetws should just read it in the appropriate manner to
allow propagation of it in the same form throughout the programme.
-- System Information:
Debian Release: 4.0
APT prefers stable
APT policy: (500, 'stable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-6-686
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Versions of packages libc6 depends on:
ii tzdata 2007k-1etch1 Time Zone and Daylight Saving Time
libc6 recommends no packages.
-- no debconf information
Reply to: