nerdexam
CompTIA

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…

Research, Development and Collaboration

Question

Which of the following vulnerabilities did the analyst uncover?

Exhibit

CAS-003 question #964 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)
  • A
    3% (2)
  • B
    9% (6)
  • C
    83% (53)
  • D
    5% (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

#buffer overflow#secure coding#vulnerability analysis#strcpy

Community Discussion

No community discussion yet for this question.

Full CAS-003 Practice