nerdexam
CompTIA

CS0-003 · Question #99

An internally developed file-monitoring system identified the following except as causing a program to crash often: char filedata[100]; fp = fopen(access.log, r); srtcopy (filedata, fp); printf…

The correct answer is B. Replace the strcpy function. Use of insecure functions can make it much harder to secure code. Functions like strcpy, which don't have critical security features built in, can result in code that is easier for attackers to target. In fact, strcpy is the only specific function that the CySA+ objectives call…

Submitted by hassan_iq· Mar 6, 2026Vulnerability Management

Question

An internally developed file-monitoring system identified the following except as causing a program to crash often:

char filedata[100]; fp = fopen(access.log, r); srtcopy (filedata, fp); printf (%s\n, filedata); Which of the following should a security analyst recommend to fix the issue?

Options

  • AOpen the access.log file in read/write mode.
  • BReplace the strcpy function.
  • CPerform input sanitization.
  • DIncrease the size of the file data butter.

How the community answered

(57 responses)
  • A
    4% (2)
  • B
    70% (40)
  • C
    18% (10)
  • D
    9% (5)

Explanation

Use of insecure functions can make it much harder to secure code. Functions like strcpy, which don't have critical security features built in, can result in code that is easier for attackers to target. In fact, strcpy is the only specific function that the CySA+ objectives call out, likely because of how commonly it is used for buffer overflow attacks in applications written in C. strcpy allows data to be copied without caring whether the source is bigger than the destination. If this occurs, attackers can place arbitrary data in memory locations past the original destination, possibly allowing a buffer overflow attack to succeed.

Topics

#Buffer overflow#Secure coding#strcpy#Vulnerability remediation

Community Discussion

No community discussion yet for this question.

Full CS0-003 Practice