Question
Code Given: #include #include #include /* * Program to illustrate data references that overrun intended bounds. * Compile this with gcc -m32 -g -o mystuff
Code Given:
#include
void showMemory(struct myData data){ /* temporary variables */ int offset; int result; /* Show memory values at offsets into the public data field */ while(1){ printf("Enter an offset into your public data and we'll show you the character value. (or q to quit) "); result = scanf("%d", &offset); if(result == 0){ break; } printf("Hex value at offset %d (address 0x%p) is 0x%x ", offset, &data.public_info[offset], data.public_info[offset]); } } void handleMyStuff(){ /* Declare myData variable my_data */ struct myData my_data;
/* Initialized my_data */ setData(&my_data);
/* Display address of my_data fields */ printf("Adress of public data:\t\t0x%p Address of secret PIN:\t\t0x%p ", &my_data.public_info[0], &my_data.pin); printf(" ");
/* Display values of my_data fields */ printf("Public data is %s ", my_data.public_info); printf("Hex value of PIN is 0x%x ", my_data.pin); printf(" "); showMemory(my_data); } int main(int argc, char *argv[]) { handleMyStuff(); printf(" Bye "); }
Results may vary, but review Example 1 and Answer the question:
Address of public data: OxOxffc55d80 Address of secret PIN: OxOxffc55db4 Public data is I yam what I yam. Hex value of PIN is 0x63 Enter an offset into your public data and we'll show you the character value. (or q to quit)Address of public data: Oxoxffec08co Address of secret PIN: OxOxffec08f4 Public data is I yam what I yam. Hex value of PIN is 0x63 Enter an offset into your public data and we'll show you the character valueStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started