secure_programming
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| secure_programming [2012/09/30 22:47] – javapimp | secure_programming [2023/08/18 18:15] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 26: | Line 26: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | ===== Function returns the same value for success or failure ===== | ||
| + | |||
| ====== Buffer Overflows ====== | ====== Buffer Overflows ====== | ||
| Line 31: | Line 34: | ||
| ====== Memory Leaks ====== | ====== Memory Leaks ====== | ||
| + | ====== Memory Allocation ====== | ||
| + | <code cpp> | ||
| + | #ifdef CHECK_ALLOC | ||
| + | #define MALLOC bad_malloc | ||
| + | #else | ||
| + | #define MALLOC malloc | ||
| + | #endif | ||
| + | |||
| + | #define FAIL_COUNT = 3; | ||
| + | void* bad_malloc(size_t size) | ||
| + | { | ||
| + | | ||
| + | void* ret = NULL; | ||
| + | | ||
| + | ret = malloc(size); | ||
| + | else | ||
| + | fail = FAIL_COUNT; | ||
| + | | ||
| + | } | ||
| + | </ | ||
| ====== Heap Corruption ====== | ====== Heap Corruption ====== | ||
| + | |||
| + | ===== Electric Fence ===== | ||
| + | <code bash> | ||
| + | $ gcc -o foo foo.c -lefence | ||
| + | </ | ||
| ====== Race Conditions ====== | ====== Race Conditions ====== | ||
| + | |||
| + | ====== Code Coverage ====== | ||
| + | <code bash> | ||
| + | $ gcc -ftest-coverage -fprofile-arcs foo.c | ||
| + | $ gcov foo.c | ||
| + | </ | ||
| + | |||
| + | ====== Automated Tools ====== | ||
| + | <code bash> | ||
| + | $ splint -I/inc *.c | ||
| + | </ | ||
secure_programming.1349045267.txt.gz · Last modified: 2023/08/18 18:15 (external edit)