1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[]) {

    int* a = malloc(sizeof(*a) * 3);

    // INVALID READ
    int n = a[100];


    free(a);
    return EXIT_SUCCESS;
}

/*
==27550== Invalid read of size 4
==27550==    at 0x4005C7: main (buffer_overread.c:9)
==27550==  Address 0x4c3e1d0 is not stack'd, malloc'd or (recently) free'd
==27550==
==27550==
==27550== HEAP SUMMARY:
==27550==     in use at exit: 0 bytes in 0 blocks
==27550==   total heap usage: 1 allocs, 1 frees, 12 bytes allocated
==27550==
==27550== All heap blocks were freed -- no leaks are possible
*/
/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */

© Copyright 2017 Alexander J. Quinn         This content is protected and may not be shared, uploaded, or distributed.