mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2024-10-01 01:36:01 -04:00
tweak canary awareness in offset test
This commit is contained in:
parent
64b655f062
commit
1d2c10f5bb
@ -2,7 +2,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static const unsigned size_classes[] = {
|
#include "../config.h"
|
||||||
|
|
||||||
|
static unsigned size_classes[] = {
|
||||||
/* large */ 4 * 1024 * 1024,
|
/* large */ 4 * 1024 * 1024,
|
||||||
/* 0 */ 0,
|
/* 0 */ 0,
|
||||||
/* 16 */ 16, 32, 48, 64, 80, 96, 112, 128,
|
/* 16 */ 16, 32, 48, 64, 80, 96, 112, 128,
|
||||||
@ -17,15 +19,16 @@ static const unsigned size_classes[] = {
|
|||||||
|
|
||||||
#define N_SIZE_CLASSES (sizeof(size_classes) / sizeof(size_classes[0]))
|
#define N_SIZE_CLASSES (sizeof(size_classes) / sizeof(size_classes[0]))
|
||||||
|
|
||||||
static size_t canary_size = 8;
|
static const size_t canary_size = SLAB_CANARY ? sizeof(uint64_t) : 0;
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
for (unsigned i = 2; i < N_SIZE_CLASSES; i++) {
|
||||||
|
size_classes[i] -= canary_size;
|
||||||
|
}
|
||||||
|
|
||||||
void *p[N_SIZE_CLASSES];
|
void *p[N_SIZE_CLASSES];
|
||||||
for (unsigned i = 0; i < N_SIZE_CLASSES; i++) {
|
for (unsigned i = 0; i < N_SIZE_CLASSES; i++) {
|
||||||
unsigned size = size_classes[i];
|
unsigned size = size_classes[i];
|
||||||
if (size) {
|
|
||||||
size -= canary_size;
|
|
||||||
}
|
|
||||||
p[i] = malloc(size);
|
p[i] = malloc(size);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user