Bug#692783: libc6: fcloseall() doesn't close any streams
Package: libc6
Version: 2.13-36
Severity: normal
Tags: security
The fcloseall() function is supposed to close all open streams,
including std{in,out,err}. It doesn't close any:
$ cat fcloseall.c
#define _GNU_SOURCE
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void
syserr(char *msg)
{
fflush(NULL);
fprintf(stderr, "%s: %s\n", msg, strerror(errno));
exit(EXIT_FAILURE);
}
int
main(void)
{
FILE *nulldev = fopen("/dev/null", "r");
char data[1];
if (!nulldev)
syserr("fopen");
if (fcloseall())
syserr("fcloseall");
fread(data, sizeof(data), 1, nulldev);
if (ferror(nulldev))
syserr("fread");
return 0;
}
$ gcc -Wall -Wextra -fno-builtin fcloseall.c
$ ./a.out; echo $?
0
$
The bug may also result in a security problem if a program like
'start-stop-daemon -c' uses fcloseall() to close its file descriptors.
-- System Information:
Debian Release: wheezy/sid
APT prefers testing
APT policy: (500, 'testing'), (400, 'unstable'), (300, 'experimental')
Architecture: i386 (x86_64)
Kernel: Linux 3.6.5 (SMP w/2 CPU cores)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages libc6 depends on:
ii libc-bin 2.13-36
ii libgcc1 1:4.7.1-7
Versions of packages libc6 recommends:
ii libc6-i686 2.13-36
Versions of packages libc6 suggests:
ii debconf [debconf-2.0] 1.5.46
ii glibc-doc 2.13-36
ii locales 2.13-36
-- debconf information excluded
Reply to: