For the next program, there is buffer overflow present. Your task is to fix the
ID: 3720595 • Letter: F
Question
For the next program, there is buffer overflow present. Your task is to fix the code so that buffer overflow can be avoided Here is the link for the mentioned article: H. Shahriar et al., "Buffer Overflow Patching for Cand C++ Programs Rule-Based Approach," ACM SIGAPP Applied Computing Review, Vol. 13, Issue 2, June 2013, pp. 8-19 Kennesaw Digital Library void main ) char src[10]: printf ("enter name) gets (src); void main O char *src-"hello world"; 1) char dest[5]; memcpy (dest, src, 10); void main (f char src[10]; printf (enter name"); fgets (src, sizeof(src), stdin); void main O char *src-"hello world" char dest[5]; int n = sizeof (src); if (sizeof (dest)Explanation / Answer
The answer would be
2) void main(){
char src[10];
printf("enter name");
fgets(src,sizeof(src),stdin);
printf("%s",src);
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.