Skip to content

Instantly share code, notes, and snippets.

@iximeow
Created August 11, 2022 00:50
Show Gist options
  • Save iximeow/a663add82dd5305879499419156ff5be to your computer and use it in GitHub Desktop.
Save iximeow/a663add82dd5305879499419156ff5be to your computer and use it in GitHub Desktop.
#include <assert.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <fcntl.h>
int main() {
int fd = open("doesnotexist", O_CREAT);
assert(fd > 0);
void* map = mmap(NULL, 65536, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
assert((long long)map != -1);
((char*)map)[4095] = 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment