*** *** 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

Systems Architecture
7th Edition
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Stephen D. Burd
Chapter11: Operating Systems
Section: Chapter Questions
Problem 30VE
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning