include <sys/mman.h>

include <err.h>

include <stdio.h>

include <stdlib.h>

include <string.h>

typedef void (*fn)(void);

define SLABSIZE 4096

int

main(int argc, char *argv[])

{

int value = 41;

void *slab = malloc(SLABSIZE);

if (!slab) err(1, "malloc");

memset(slab, 0xC3, SLABSIZE); // RET not INT3

if (mprotect(slab, SLABSIZE, PROT_EXEC) != 0) err(1, "mprotect");

fn call = slab;

call();

printf("%d\n", value);

}

Proxy Information
Original URL
gemini://thrig.me/software/assembly/slab-of-code/ret.c
Status Code
Success (20)
Meta
text/plain
Capsule Response Time
1001.224926 milliseconds
Gemini-to-HTML Time
0.360291 milliseconds

This content has been proxied by September (ba2dc).