Question: The functions intlen, len, and iptoa provide a very convoluted way to compute the number of decimal digits required to represent an integer. We will

The functions intlen, len, and iptoa provide a very convoluted way to compute the number of decimal digits required to represent an integer. We will use this as a way to study some aspects of the gcc stack protector facility.

int len(char *s) { return strlen(s); } void iptoa (char *s, long *p) { long val *p; sprintf (s,

The following show portions of the code for intlen, compiled both with and without stack protector:

(a) Without protector

1 2 3  4 5 6 1 2 3 4 5 6 7 (b) With protector 00 int intlen (long x) x in %rdi intlen: subq movg 8 9 leaq

A. For both versions: What are the positions in the stack frame for buf, v, and (when present) the canary value?

B. How does the rearranged ordering of the local variables in the protected code provide greater security against a buffer overrun attack?

int len(char *s) { return strlen(s); } void iptoa (char *s, long *p) { long val *p; sprintf (s, "%ld", val); } = int intlen (long x) { long v; char buf [12]; } V = x; iptoa (buf, &v); return len (buf);

Step by Step Solution

3.47 Rating (154 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

This problem gives you another chance to see how x8664 ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Systems A Programmers Perspective Questions!