mirror of
https://github.com/cuberite/polarssl.git
synced 2025-08-18 18:16:14 -04:00
Metatests for null pointer dereference
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
30380dacdb
commit
21d8d59ce2
@ -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 */
|
/* Command line entry point */
|
||||||
/****************************************************************/
|
/****************************************************************/
|
||||||
@ -40,6 +63,8 @@ typedef struct {
|
|||||||
|
|
||||||
metatest_t metatests[] = {
|
metatest_t metatests[] = {
|
||||||
{ "test_fail", "any", meta_test_fail },
|
{ "test_fail", "any", meta_test_fail },
|
||||||
|
{ "null_dereference", "any", null_pointer_dereference },
|
||||||
|
{ "null_call", "any", null_pointer_call },
|
||||||
{ NULL, NULL, NULL }
|
{ NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user