CAS-004 Exam QuestionsBrowse all questions from this exam

CAS-004 Exam - Question 434


A security architect examines a section of code and discovers the following:

char username[20]

char password[20]

gets(username)

checkUserExists(username)

Which of the following changes should the security architect require before approving the code for release?

Show Answer
Correct Answer: C

The code snippet is vulnerable to a buffer overflow attack due to the use of the gets function, which does not limit the input size. This can lead to memory corruption and potential security vulnerabilities. By ensuring that no more than 20 characters are entered, the code can prevent buffer overflow attacks, thus mitigating a significant security risk.

Discussion

2 comments
Sign in to comment
isaphiltrickOption: C
Jul 6, 2024

The code snippet provided is vulnerable to a buffer overflow attack due to the use of the gets function, which does not limit the input size. This can lead to memory corruption and potential security vulnerabilities. By ensuring that no more than 20 characters are entered, the code can prevent buffer overflow attacks, thus mitigating a significant security risk.

ChopSNapOption: C
Jul 16, 2024

The best change the security architect should require before approving the code for release is C. Prevent more than 20 characters from being entered. his is essential because gets() does not perform bounds checking, leading to a buffer overflow risk. It’s crucial to ensure that input does not exceed the allocated buffer size.