null3.c
up: index
prev: null2.c
next: null4.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cheriintrin.h>
#include "capprint.h"
int main()
{
unsigned char nullrepr0[sizeof(void*)] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
unsigned char nullrepr1[sizeof(void*)] = {0,0,0,0,0,0,0,0,5,0,1,0,0,0,0,0};
void *p0=NULL,*p1;
if(memcmp(&p0, nullrepr0, sizeof(void*))==0)
fprintf(stderr,"NULL representation is all zeroes\n");
for(unsigned int i=0;i<sizeof(void*);i++)
{
((unsigned char*)&p0)[i]=nullrepr0[i];
((unsigned char*)&p1)[i]=nullrepr1[i];
}
if(p0==NULL) fprintf(stderr,"p0 == NULL\n");
if(p1==NULL) fprintf(stderr,"p1 == NULL\n");
if(p0==p1) fprintf(stderr,"p0 == p1\n");
fprintf(stderr,"p0: %s, which is %s\n", null_sptr(p0), isnulls(p0));
fprintf(stderr,"p1: %s, which is %s\n", null_sptr(p1), isnulls(p1));
}
Experimental data (what does this mean?)
cerberus-cheri
cerberus-cheri-no-pnvi
cerberus-cheri-revocation
cerberus-cheri-revocation-no-pnvi
cerberus-cheri-cornucopia
cerberus-cheri-cornucopia-no-pnvi NULL representation is all zeroes
p0 == NULL
p1 == NULL
p0 == p1
p0: 0x0 [,0x0 - 0xffffffffffffffff] (invalid), which is null
p1: 0x0 [,0x0 - 0xffffffffffffffff] (invalid), which is null
clang-riscv-O0-bounds-conservative
clang-riscv-O3-bounds-conservative
clang-riscv-O0-bounds-references-only
clang-riscv-O0-bounds-subobject-safe
clang-riscv-O3-bounds-subobject-safe
clang-riscv-O0-bounds-aggressive
clang-riscv-O0-bounds-very-aggressive
clang-riscv-O0-bounds-everywhere-unsafe NULL representation is all zeroes
p0 == NULL
p1 == NULL
p0 == p1
p0: 0 [,0 - 0xffffffffffffffff] (invalid), which is null
p1: 0 [,0 - 0x20000000] (invalid), which is null
clang-morello-O0-bounds-conservative
clang-morello-O3-bounds-conservative
clang-morello-O0-bounds-references-only
clang-morello-O0-bounds-subobject-safe
clang-morello-O3-bounds-subobject-safe
clang-morello-O0-bounds-aggressive
clang-morello-O0-bounds-very-aggressive
clang-morello-O0-bounds-everywhere-unsafe NULL representation is all zeroes
p0 == NULL
p1 == NULL
p0 == p1
p0: 0 [,0 - 0xffffffffffffffff] (invalid), which is null
p1: 0 [,0 - 0xffffffffffffffff] (invalid), which is null
gcc-morello-O0
gcc-morello-O3 NULL representation is all zeroes
p0 == NULL
p1 == NULL
p0 == p1
p0: 0x0 [,0x0-0xffffffffffffffff] (invalid), which is null
p1: 0x0 [,0x0-0xffffffffffffffff] (invalid), which is null