nerdexam
GIAC

GCIH · Question #299

Which of the following functions in c/c++ can be the cause of buffer overflow? Each correct answer represents a complete solution. Choose two.

The correct answer is B. strcat() C. strcpy(). strcpy() and strcat() are unsafe C/C++ standard library functions that perform string operations without bounds checking, making them classic sources of buffer overflow vulnerabilities.

Vulnerability Exploitation & Privilege Escalation

Question

Which of the following functions in c/c++ can be the cause of buffer overflow? Each correct answer represents a complete solution. Choose two.

Options

  • Aprintf()
  • Bstrcat()
  • Cstrcpy()
  • Dstrlength()

How the community answered

(66 responses)
  • A
    3% (2)
  • B
    89% (59)
  • D
    8% (5)

Why each option

strcpy() and strcat() are unsafe C/C++ standard library functions that perform string operations without bounds checking, making them classic sources of buffer overflow vulnerabilities.

Aprintf()

printf() is primarily associated with format string vulnerabilities when user-controlled input is passed as the format argument, not with classic buffer overflow caused by unchecked memory writes.

Bstrcat()Correct

strcat() appends a source string to a destination buffer without verifying that the destination has sufficient space to hold the result, allowing writes beyond the allocated buffer boundary.

Cstrcpy()Correct

strcpy() copies a source string into a destination buffer without checking the destination size, so if the source is longer than the allocated buffer, it will overwrite adjacent memory and cause a buffer overflow.

Dstrlength()

strlength() is not a valid C/C++ standard library function - the correct function is strlen() - and strlen() only reads string length without writing to any buffer, so it cannot cause a buffer overflow.

Concept tested: Unsafe C/C++ string functions causing buffer overflow

Source: https://owasp.org/www-community/vulnerabilities/Buffer_Overflow

Topics

#buffer overflow#unsafe C functions#strcat#strcpy

Community Discussion

No community discussion yet for this question.

Full GCIH Practice