Subject: lib/27283: incorrect check for mmap return value in citrus_mmap.c
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <o.vd.linden@quicknet.nl>
List: netbsd-bugs
Date: 10/17/2004 23:22:52
>Number:         27283
>Category:       lib
>Synopsis:       incorrect check for mmap return value in citrus_mmap.c
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 17 21:48:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Onno van der Linden
>Release:        NetBSD 2.99.9
>Organization:
	
>Environment:
	
	
System: NetBSD sheep 2.99.9 NetBSD 2.99.9 (SHEEP) #0: Wed Oct 13 17:13:45 MEST 2004 onno@sheep:/usr/src/sys/arch/i386/compile/SHEEP i386
Architecture: i386
Machine: i386
>Description:
	in _citrus_map_file() the return value of mmap should be checked
        for MAP_FAILED or -1 not for 0.
>How-To-Repeat:
	
>Fix:

*** /usr/src/lib/libc/citrus/citrus_mmap.c.orig	Sun Oct 17 23:12:58 2004
--- /usr/src/lib/libc/citrus/citrus_mmap.c	Sun Oct 17 23:01:52 2004
***************
*** 71,77 ****
  	}
  	head = mmap(NULL, (size_t)st.st_size, PROT_READ, MAP_FILE|MAP_PRIVATE,
  		    fd, (off_t)0);
! 	if (!head) {
  		ret = errno;
  		close(fd);
  		return ret;
--- 71,77 ----
  	}
  	head = mmap(NULL, (size_t)st.st_size, PROT_READ, MAP_FILE|MAP_PRIVATE,
  		    fd, (off_t)0);
! 	if (head == MAP_FAILED) {
  		ret = errno;
  		close(fd);
  		return ret;
>Release-Note:
>Audit-Trail:
>Unformatted: