Lecture7-revised version

Lecture7-revised version - Buffer Overruns Week 7 Memory...

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

View Full Document Right Arrow Icon
Buffer Overruns Week 7
Background image of page 1

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

View Full DocumentRight Arrow Icon
Memory
Background image of page 2
The Stack • Contiguous block of memory containing data • The stack pointer (SP) points to top of stack • Bottom of stack is at a fixed address
Background image of page 3

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

View Full DocumentRight Arrow Icon
The Frame • Stack consists of logical stack frames that are pushed when calling a function and popped when returning • Stack frame contains parameters to function, local variables, and data necessary to recover previous stack frame including the instruction pointer at the time of the function call • Frame pointer (FP) points to fixed location within a frame and variables are referenced by offsets to the FP
Background image of page 4
Calling a Procedure • Save previous FP • Copies SP into FP to create the FP • Advances SP to reserve space for the local variables
Background image of page 5

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

View Full DocumentRight Arrow Icon
Buffer overflows • Result of stuffing more data into a buffer than it can handle
Background image of page 6
Stack Frame Structure
Background image of page 7

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

View Full DocumentRight Arrow Icon
void function(char *str) { char buffer[16]; strcpy(buffer,str); } int main() { char large_string[256]; int i; for( i = 0; i < 255; i++) large_string[i] = 'A'; function(large_string); return 0;
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/16/2011 for the course CS35L 187105201 taught by Professor Pope during the Spring '10 term at UCLA.

Page1 / 19

Lecture7-revised version - Buffer Overruns Week 7 Memory...

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

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