Skip to content

Commit 14eadbf

Browse files
authored
fix some typo and error
1 parent 428a0f6 commit 14eadbf

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

calc_tcache_idx.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ int main()
5050
unsigned long long tidx;
5151
fprintf(stderr, "This file doesn't demonstrate an attack, but calculates the tcache idx for a given chunk size.\n");
5252
fprintf(stderr, "The basic formula is as follows:\n");
53-
fprintf(stderr, "\t(IDX = CHUNKSIZE - MINSIZE + MALLOC_ALIGNMENT - 1) / MALLOC_ALIGNMENT\n");
53+
fprintf(stderr, "\tIDX = (CHUNKSIZE - MINSIZE + MALLOC_ALIGNMENT - 1) / MALLOC_ALIGNMENT\n");
5454
fprintf(stderr, "\tOn a 64 bit system the current values are:\n");
5555
fprintf(stderr, "\t\tMINSIZE: 0x%lx\n", MINSIZE);
5656
fprintf(stderr, "\t\tMALLOC_ALIGNMENT: 0x%lx\n", MALLOC_ALIGNMENT);
5757
fprintf(stderr, "\tSo we get the following equation:\n");
58-
fprintf(stderr, "\t(IDX = CHUNKSIZE - 0x%lx) / 0x%lx\n\n", MINSIZE-MALLOC_ALIGNMENT+1, MALLOC_ALIGNMENT);
58+
fprintf(stderr, "\tIDX = (CHUNKSIZE - 0x%lx) / 0x%lx\n\n", MINSIZE-MALLOC_ALIGNMENT+1, MALLOC_ALIGNMENT);
5959
fprintf(stderr, "BUT be AWARE that CHUNKSIZE is not the x in malloc(x)\n");
6060
fprintf(stderr, "It is calculated as follows:\n");
61-
fprintf(stderr, "\tIF x < MINSIZE(0x%lx) CHUNKSIZE = MINSIZE (0x%lx)\n", MINSIZE, MINSIZE);
61+
fprintf(stderr, "\tIF x + SIZE_SZ + MALLOC_ALIGN_MASK < MINSIZE(0x%lx) CHUNKSIZE = MINSIZE (0x%lx)\n", MINSIZE, MINSIZE);
6262
fprintf(stderr, "\tELSE: CHUNKSIZE = (x + SIZE_SZ + MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK) \n");
63-
fprintf(stderr, "\t=> CHUNKSIZE = (x + 0x%lx + 0x%lx) & ~0x%lx)\n\n\n", SIZE_SZ, MALLOC_ALIGN_MASK, MALLOC_ALIGN_MASK);
63+
fprintf(stderr, "\t=> CHUNKSIZE = (x + 0x%lx + 0x%lx) & ~0x%lx\n\n\n", SIZE_SZ, MALLOC_ALIGN_MASK, MALLOC_ALIGN_MASK);
6464
while(1) {
6565
fprintf(stderr, "[CTRL-C to exit] Please enter a size x (malloc(x)) in hex (e.g. 0x10): ");
6666
scanf("%llx", &req);
@@ -71,4 +71,4 @@ int main()
7171
fprintf(stderr, "\nTCache Idx: %llu\n", tidx);
7272
}
7373
return 0;
74-
}
74+
}

0 commit comments

Comments
 (0)