*** *** Saved frame pointer Return address Stack structure foobar(char *args) { unsigned int a = 4; unsigned int b = 8; static long c = 1234567890; short buf[4]; strncpy(buf, args, 24); ain(int argc, char *argv[]) { foobar(argv[1]); return 0; ill variable "a" be overwritten by strncpy and will "b" and "c" also be overwritten? Briefly ain. ill saved frame pointer be overwritten? If yes, how many bytes of the saved frame pointer can werwritten? Briefly explain. Il the return address of foobar be overwritten? If yes, how many bytes of it can be written? Briefly explain. Local variables

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

P1

Q5) Consider the following program loaded to a 32-bit x86 architecture. Suppose the stack frame
is with space allocated only for the variables shown, and there is no memory gap between the
local variable and saved frame pointer. Assume the user input is sufficiently long.
Local variables
Saved frame pointer
Return address
Stack structure
void foobar(char *args) {
unsigned int a = 4;
unsigned int b = 8;
static long c = 1234567890;
short buf[4];
strncpy(buf, args, 24);
}
int main(int argc, char *argv[]) {
foobar(argv[1]);
return 0;
}
a) Will variable "a" be overwritten by strncpy and will "b" and "c" also be overwritten? Briefly
explain.
b) Will saved frame pointer be overwritten? If yes, how many bytes of the saved frame pointer can
be overwritten? Briefly explain.
c) Will the return address of foobar be overwritten? If yes, how many bytes of it can be
overwritten? Briefly explain.
Transcribed Image Text:Q5) Consider the following program loaded to a 32-bit x86 architecture. Suppose the stack frame is with space allocated only for the variables shown, and there is no memory gap between the local variable and saved frame pointer. Assume the user input is sufficiently long. Local variables Saved frame pointer Return address Stack structure void foobar(char *args) { unsigned int a = 4; unsigned int b = 8; static long c = 1234567890; short buf[4]; strncpy(buf, args, 24); } int main(int argc, char *argv[]) { foobar(argv[1]); return 0; } a) Will variable "a" be overwritten by strncpy and will "b" and "c" also be overwritten? Briefly explain. b) Will saved frame pointer be overwritten? If yes, how many bytes of the saved frame pointer can be overwritten? Briefly explain. c) Will the return address of foobar be overwritten? If yes, how many bytes of it can be overwritten? Briefly explain.
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Randomized Select Algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education