{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lec9 - Lecture 9 Assertions and Error Handling CS240...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 9 Assertions and Error Handling CS240 Wednesday, February 9, 2011
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
The C preprocessor The C compiler performs Macro expansion and directive handling Preprocessing directive lines, including file inclusion and conditional compilation, are executed. The preprocessor simultaneously expands macros Example: Specify how you want to macro expand by specifying the DEBUG variable at compilation time in the Makefile gcc -D option #ifdef DEBUG #define DPRINT(s) fprintf(stderr,”%s\n”,s) #else #define DPRINT(s) #endif Wednesday, February 9, 2011
Background image of page 2
The C preprocessor The C compiler performs Macro expansion and directive handling Preprocessing directive lines, including file inclusion and conditional compilation, are executed. The preprocessor simultaneously expands macros DPRINT( makeString(“error”, CAUSE) ); Question: Is function makeString() called? Shouldn’t we have some cutesy pictures that make the slides look cool and humorous? Wednesday, February 9, 2011
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
How can this code fail? #include <stdio.h> int main() { int a, b, c; a = 10; b = getchar () - 48; c = a/b; return 0; } No! Go Away! Wednesday, February 9, 2011
Background image of page 4
Common Software Vulnerabilities Buffer overflows Input validation Format string problems Integer overflows Failing to handle errors Other exploitable logic errors 5 Wednesday, February 9, 2011
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Weak Types and Errors Would strong typing prevent these kinds of vulnerabilities?
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}