DragonFly BSD
DragonFly bugs List (threaded) for 2011-09
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

[issue2131] mmap() with size == 0 returns ptr to ld-elf.so.2


From: "Venkatesh Srinivas \(via DragonFly issue tracker\)" <sinknull@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 12 Sep 2011 03:33:26 +0000

New submission from Venkatesh Srinivas <vsrinivas@dragonflybsd.org>:

mmap passed a size of 0 with PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON returns
a pointer to the base of the mapped ld-elf.so.2 rather than an EINVAL, which is
the expected return for len = 0.

---

#include <stdlib.h>
#include <sys/mman.h>

main() {
	char *buf = mmap(NULL, 0, PROT_READ|PROT_WRITE,
			MAP_PRIVATE|MAP_ANON, -1, 0);
	printf("%p \n", buf);
	pause();
}

demonstrates; look at /proc/<pid>/map after the mmap().

----------
messages: 10108
nosy: vsrinivas
status: unread
title: mmap() with size == 0 returns ptr to ld-elf.so.2

_____________________________________________________
DragonFly issue tracker <bugs@lists.dragonflybsd.org>
<http://bugs.dragonflybsd.org/issue2131>
_____________________________________________________




[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]