CAS-003 · Question #964
Which of the following vulnerabilities did the analyst uncover?
The correct answer is C. A buffer overflow when using the command stropy(variable2) variable1[1]). The code in question uses strcpy(variable2, variable1[1]), which copies the contents of variable1[1] into variable2. strcpy() performs no bounds checking - if variable1[1] contains more bytes than variable2 can hold, the excess data overwrites adjacent memory on the stack. This…
Question
Which of the following vulnerabilities did the analyst uncover?
Exhibit
Options
- AA memory leak when executing exit (0);
- BA race condition when switching variables in stropy(variable2) variable[1]);
- CA buffer overflow when using the command stropy(variable2) variable1[1]);
- DError handling when executing principle ("stropy () failed. \n." >;
How the community answered
(64 responses)- A3% (2)
- B9% (6)
- C83% (53)
- D5% (3)
Explanation
The code in question uses strcpy(variable2, variable1[1]), which copies the contents of variable1[1] into variable2. strcpy() performs no bounds checking - if variable1[1] contains more bytes than variable2 can hold, the excess data overwrites adjacent memory on the stack. This is the definition of a stack-based buffer overflow, a critical vulnerability class that can lead to arbitrary code execution. Option A is wrong because exit(0) is a normal, clean program exit that frees all resources; it does not cause a memory leak. Option B is wrong because the scenario does not involve concurrent thread execution or shared state access patterns that characterize a race condition. Option D is wrong because calling printf to report an error is standard error handling and does not represent a vulnerability in this context.
Topics
Community Discussion
No community discussion yet for this question.
