Project

General

Profile

Actions

Bug #2131

closed

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

Added by vsrinivas over 12 years ago. Updated over 12 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

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().

Actions #1

Updated by vsrinivas over 12 years ago

Closed by 06cee6ba38d901952e904cbb86c1f3fa6e5d97de.

Actions

Also available in: Atom PDF