Subject: lib/6322: fclose(NULL) segfaults
To: None <gnats-bugs@gnats.netbsd.org>
From: None <dbj@netbsd.org>
List: netbsd-bugs
Date: 10/17/1998 19:28:47
>Number: 6322
>Category: lib
>Synopsis: fclose(NULL) segfaults
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people (Library Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Oct 17 16:35:00 1998
>Last-Modified:
>Originator: Darrin B. Jewell
>Organization:
>Release: 1.3.2 as well as -current updated around 19981011.1745
>Environment:
System: NetBSD pan-fried-peking-ravioli 1.3H NetBSD 1.3H (PAN-FRIED-PEKING-RAVIOLI) #3: Sun Oct 11 21:20:20 EDT 1998 jewell@pan-fried-peking-ravioli:/u2/PAN-FRIED-PEKING-RAVIOLI i386
>Description:
fclose(NULL) produces a segmentation fault error.
Perhaps it should return EOF and set errno to EBADF.
Then again perhaps the users deserve what they get for handing
random junk to libc functions.
>How-To-Repeat:
Compile and run the following program:
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
int
main(int argc, char *argv[])
{
int ret;
ret = fclose(NULL);
assert(ret == EOF);
perror("fclose");
return(EXIT_SUCCESS);
}
>Fix:
>Audit-Trail:
>Unformatted: