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 DocumentRight Arrow Icon
The C preprocessor The C compiler performs Macro expansion and directive handling Preprocessing directive lines, including Fle 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 MakeFle 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 Fle 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 DocumentRight Arrow Icon
How can this code fail? #include <stdio.h> int main() { int a, b, c; a = 1 0 ; b = getchar () - 48; c = a / b ; return 0; } No! Go Away! Wednesday, February 9, 2011
Background image of page 4
Common Software Vulnerabilities Buffer overFows Input validation ±ormat string problems Integer overFows ±ailing 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 DocumentRight Arrow Icon
Weak Types and Errors Would strong typing prevent these kinds of vulnerabilities? What kind of errors do type systems typically catch?
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.

This note was uploaded on 02/23/2012 for the course CS 240 taught by Professor Rego during the Spring '08 term at Purdue University-West Lafayette.

Page1 / 19

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

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online