Certified Ethical Hacker (CEH v10) — Question 103
Which of the following programming languages is most susceptible to buffer overflow attacks, due to its lack of a built-in bounds checking mechanism?
Code:
#include <string.h>
int main(){
char buffer[8];
strcpy(buffer, ""11111111111111111111111111111"");
}
Output:
Segmentation fault -
Answer options
- A. C#
- B. Python
- C. Java
- D. C++
Correct answer: D
Explanation
C++ is the correct answer because it allows direct memory manipulation without automatic bounds checking, making it prone to buffer overflow vulnerabilities. On the other hand, languages like C#, Python, and Java have built-in mechanisms to prevent such issues, thereby reducing the risk of buffer overflow attacks.