44#include "iso_alloc.h"
55#include "iso_alloc_internal.h"
66
7- #if defined(UAF_PTR_PAGE ) && !defined(ALLOC_SANITY )
8- /* This test should be run manually. You need to enable UAF_PTR_PAGE
9- * and then disable the sampling logic in iso_alloc. */
7+ #if UAF_PTR_PAGE && !ALLOC_SANITY
8+ /* This test should be run manually after enabling UAF_PTR_PAGE
9+ * and disabling the sampling mechanism before the call to
10+ * _iso_alloc_ptr_search in _iso_free_internal_unlocked */
1011typedef struct test {
1112 char * str ;
1213} test_t ;
@@ -15,14 +16,19 @@ int main(int argc, char *argv[]) {
1516 void * str = iso_alloc (32 );
1617 test_t * test = (test_t * ) iso_alloc (1024 );
1718 test -> str = str ;
18- memcpy (str , "a string!" , 9 );
19- iso_free (str );
19+
20+ const char * s = "a string!" ;
21+ memcpy (str , s , strlen (s ));
22+
23+ /* We free the chunk permanently because
24+ * it bypasses the quarantine */
25+ iso_free_permanently (str );
2026
2127 /* Dereference a pointer that should have been
2228 * detected and overwritten with UAF_PTR_PAGE */
23- LOG ( "Attempting to dereference test->str.\nWe should fault on %x" , UAF_PTR_PAGE_ADDR );
24- LOG ( "%s " , test -> str );
25- iso_free (test );
29+ fprintf ( stdout , "Dereferencing test->str @ %p. Fault address will be %lx\n" , test -> str , UAF_PTR_PAGE_ADDR );
30+ fprintf ( stdout , "[%s]\n " , test -> str );
31+ iso_free_permanently (test );
2632
2733 return OK ;
2834}
0 commit comments