All pastes #295976 Raw Edit

Untitled

public text v1 · immutable
#295976 ·published 2006-12-29 21:43 UTC
rendered paste body
#include <stdio.h>
#include <stdlib.h>

int main (void) {
        char *ptr  = malloc(1024);
        char *ptr2;
        int heap = (int)ptr & 0xFFF00000;
        _Bool found = 0;

        printf("ptr found at %p\n", ptr);

        for (int i = 0; i < 1024; i++) {
                if (!found && (((int)(ptr2 = malloc(1024)) & 0xFFF00000) == (heap + 0x100000))) {
                        printf("good heap allignment found on malloc() %i (%p)\n", i, ptr2);
                        found = 1;
                        break;
                }

        }
        malloc(1024);
        fread (ptr, 1024 * 1024, 1, stdin);

        free(ptr);
        free(ptr2);
        return(0);
}