This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/11082] New: fclose(f); ftell(f); results in accesses on free'd memory


I used valgrind to find the origin of a crash. It shows that an ftell on a 
closed file performs reads and writes on memory free'd by fclose. The 
following small program (bug.c) reproduces the problem.

#include <stdio.h>

int main(int argc, char **argv)
{
  FILE *f = fopen("bug.c", "r");
  fclose(f);
  ftell(f);
}

compiler/kernel/libc versions:

gcc version 3.4.4

Linux c3svr30 2.6.9-89.0.16.ELsmp #1 SMP Tue Oct 27 03:51:52 EDT 2009 x86_64 
x86_64 x86_64 GNU/Linux

/lib/tls/libc-2.3.4.so
GNU C Library stable release version 2.3.4, by Roland McGrath et al.
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 3.4.6 20060404 (Red Hat 3.4.6-8).
Compiled on a Linux 2.4.20 system on 2007-09-12.
Available extensions:
        GNU libio by Per Bothner
        crypt add-on version 2.1 by Michael Glad and others
        Native POSIX Threads Library by Ulrich Drepper et al
        RT using linux kernel aio
        The C stubs add-on version 2.1.2.
        BIND-8.2.3-T5B
        NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
        Glibc-2.0 compatibility add-on by Cristian Gafton 
        GNU Libidn by Simon Josefsson
Thread-local storage support included.

-- 
           Summary: fclose(f); ftell(f); results in accesses on free'd
                    memory
           Product: glibc
           Version: 2.3.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: jur dot pauw at gmail dot com
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=11082

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]