Metatests for null pointer dereference
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
f309fbf0d5
commit
80ba832be6
1 changed files with 25 additions and 0 deletions
|
@ -28,6 +28,29 @@ void meta_test_fail(const char *name)
|
|||
}
|
||||
|
||||
|
||||
/****************************************************************/
|
||||
/* Platform features */
|
||||
/****************************************************************/
|
||||
|
||||
void null_pointer_dereference(const char *name)
|
||||
{
|
||||
(void) name;
|
||||
char *p;
|
||||
memset(&p, 0, sizeof(p));
|
||||
volatile char c;
|
||||
c = *p;
|
||||
(void) c;
|
||||
}
|
||||
|
||||
void null_pointer_call(const char *name)
|
||||
{
|
||||
(void) name;
|
||||
void (*p)(void);
|
||||
memset(&p, 0, sizeof(p));
|
||||
p();
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************/
|
||||
/* Command line entry point */
|
||||
/****************************************************************/
|
||||
|
@ -40,6 +63,8 @@ typedef struct {
|
|||
|
||||
metatest_t metatests[] = {
|
||||
{ "test_fail", "any", meta_test_fail },
|
||||
{ "null_dereference", "any", null_pointer_dereference },
|
||||
{ "null_call", "any", null_pointer_call },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue