Consider the following code snippet in C: char *base_url = malloc(11 * sizeof(char)); printf("Enter an 11 character URL: "); scanf("%s", base_url); char src[11]; char dst[11]; // copies base_url to src strncpy(src, base_url, 11); // copies src to dest strcpy(dst, src); printf("src: %s dst: %s\n", src, dst); Identify at least one potential buffer overflow vulnerability and explain why/how it can be exploited (i.e., not just that it’s a buffer overflow, but where the problem will manifest itself).

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter10: Pointers
Section: Chapter Questions
Problem 3PP
icon
Related questions
Question

Consider the following code snippet in C:

char *base_url = malloc(11 * sizeof(char));

printf("Enter an 11 character URL: ");

scanf("%s", base_url);

char src[11];

char dst[11];

 

// copies base_url to src

strncpy(src, base_url, 11);

 

// copies src to dest

strcpy(dst, src);

printf("src: %s dst: %s\n", src, dst);

 

  1. Identify at least one potential buffer overflow vulnerability and explain why/how it can be exploited (i.e., not just that it’s a buffer overflow, but where the problem will manifest itself).

 

 

 

 

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Concept of pointer parameter
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
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning