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/2827] New: purify reports UMRs (uninitialized memory reads) in readdir()


running the attached program on Linux (SuSE 9.2) results in purify UMR reports
as shown below.

I checked the sources for glibc 2.4 and it looks like in sysdeps/unix/opendir.c
the function __alloc_dir has some mismatch in malloc() and memset:

  DIR *dirp = (DIR *) malloc (sizeof (DIR) + allocation + pad);

.....

  memset (dirp, '\0', sizeof (DIR));


-------------------------------------------------------------
#include <sys/types.h>
#include <dirent.h>

#include <stdio.h>


int main(int argc, char** argv)
{
	DIR* d;
	struct dirent* e;

	d = opendir(".");
	if (d != NULL) {
		e = readdir(d);
		while (e != NULL) {
			printf("%s\n", e->d_name);
			e = readdir(d);
		}

		closedir(d);
	}
}

-------------------------------------------------------------

****  Purify instrumented ./a.out (pid 30822)  ****
UMR: Uninitialized memory read (311 times):
  * This is occurring while in:
        __getdents     [libc.so.6]
        readdir        [libc.so.6]
        main           [readdir.c:14]
        __libc_start_main [libc.so.6]
        _start         [crt1.o]
  * Reading 2 bytes from 0x80b405c in the heap.
  * Address 0x80b405c is 36 bytes into a malloc'd block at 0x80b4038 of 32796 bytes.
  * This block was allocated from:
        malloc         [rtlib.o]
        opendir        [libc.so.6]
        main           [readdir.c:12]
        __libc_start_main [libc.so.6]
        _start         [crt1.o]

-- 
           Summary: purify reports UMRs (uninitialized memory reads) in
                    readdir()
           Product: glibc
           Version: 2.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: stefan dot wengi at adnovum dot ch
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

------- 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]