#include #include /* assert */ #include /* malloc, free */ #include /* memcpy */ #include unsigned char domain[] = { 0xcd, 0xb5, 0x2e, 0xe2, 0x80, 0x8d, 0x21, 0xd9, 0x8e, 0xd9, 0x8e, 0xd9, 0x9e, 0xd9, 0x8e, 0xd9, 0x8e, 0xd9, 0x9e, 0xd9, 0x8e, 0xd9, 0x8e, 0xd9, 0x9e, 0xd9, 0x8e, 0xd9, 0x8e, 0xd9, 0x9e, 0xd9, 0x8e, 0x2a, 0xd9, 0x8e, 0xd9, 0x9e, 0xd9, 0x8e, 0xd9, 0x8e, 0xd9, 0x9e, 0x78, 0x6e, 0x2d, 0x2d, 0xd9, 0x9e, 0xd9, 0x8e, 0xd9, 0x8e, 0xd9, 0x8e, 0xd9, 0x9e, 0xd9, 0x8e, 0xd9, 0x9e, 0xd9, 0x8e, 0xd9, 0x8e, 0xd9, 0x8e, 0xd9, 0x9e, 0xd9, 0x8e, 0xd9, 0x8e, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x3b, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0xd9, 0xbe, 0xd9, 0x8e, 0xd9, 0x8e, 0xd9, 0x9e, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x2a, 0x75, 0x75, 0x75, 0x75, 0xdd, 0x90, 0xe2, 0x80, 0x8c, 0xdd, 0x90, 0x0b, 0xe2, 0x80, 0x8c, 0x6d, 0x6d, 0x2d, 0x2d, 0x27, 0xd9, 0xae, 0x2e, 0x58, 0x4e, 0x2d, 0x58, 0x2d, 0x6d, 0xd9, 0xa5, 0x2e, 0x18, 0x11, 0x2e, 0xdd, 0xae, 0x2e, 0x33, 0xd9, 0x90, 0x2e, 0x29, 0xd9, 0xae, 0x2a, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x75, 0x5a, 0x52, 0x2e, 0x21, 0xc7, 0x8e, 0xd9, 0x90, 0x29, 0x11, 0x2e, 0xdd, 0xae, 0x2e, 0x33, 0xd9, 0x90, 0x2e, 0x29, 0xd9, 0xae, 0x2a, 0x2e, 0xc7, 0x8e, 0xd9, 0x90, 0x29, 0x2e, 0xdd, 0xae, 0x2e, 0x33, 0xd9, 0x90, 0x2e, 0x29, 0xd9, 0xae, 0x2a, 0x2e, 0x21, 0xc7, 0x8e, 0xd9, 0x90, 0x29, 0xd9, 0xae, 0x2a, 0x2e, 0xc7, 0x8e, 0xd9, 0x90, 0x29, 0x2e, 0xdd, 0xae, 0x2e, 0x33, 0xd9, 0x90, 0x2e, 0x29, 0xc7, 0x8e, 0xd9, 0x90, 0x29, 0x26, 0xdd, 0xae, 0x2e, 0x33, 0xd9, 0xae, 0x2a, 0x2e, 0x21, 0xc7, 0x8e, 0xd9, 0x90, 0x29, 0x11, 0x00 }; unsigned int crash_dat_len = 328; static int flags[] = { 0, IDN2_NFC_INPUT, IDN2_TRANSITIONAL, IDN2_NONTRANSITIONAL, IDN2_TRANSITIONAL|IDN2_USE_STD3_ASCII_RULES, IDN2_NONTRANSITIONAL|IDN2_USE_STD3_ASCII_RULES }; static void *my_malloc_hook(size_t, const void *); static void my_free_hook(void*, const void *); static void *(*old_malloc_hook)(size_t, const void *); static void (*old_free_hook)(void *, const void *); static void *my_malloc_hook(size_t size, const void *caller) { static int x; void *result; /* restore original hooks */ __malloc_hook = old_malloc_hook; __free_hook = old_free_hook; /* call recursively */ if (rand() % 100 < 5) result = NULL; else result = malloc(size); /* save hooks */ old_malloc_hook = __malloc_hook; old_free_hook = __free_hook; printf("%d %zu %p\n",x++,size,result); /* restore our own hooks */ __malloc_hook = my_malloc_hook; __free_hook = my_free_hook; return result; } static void my_free_hook (void *ptr, const void *caller) { /* restore original hooks */ __malloc_hook = old_malloc_hook; __free_hook = old_free_hook; /* call recursively */ free(ptr); /* save hooks */ old_malloc_hook = __malloc_hook; old_free_hook = __free_hook; /* restore our own hooks */ __malloc_hook = my_malloc_hook; __free_hook = my_free_hook; } int main(void) { char *out; /* save hooks */ old_malloc_hook = __malloc_hook; old_free_hook = __free_hook; /* overwrite hooks */ __malloc_hook = my_malloc_hook; __free_hook = my_free_hook; for (unsigned it = 0; it < sizeof(flags)/sizeof(flags[0]); it++) { if (idn2_to_ascii_8z(domain, &out, flags[it]) == IDNA_SUCCESS) idn2_free(out); if (idn2_to_ascii_lz(domain, &out, flags[it]) == IDNA_SUCCESS) idn2_free(out); } /* restore hooks */ __malloc_hook = old_malloc_hook; __free_hook = old_free_hook; return 0; }