CISSP practice question · Software Development Security
A C service computes a buffer size as count multiplied by record size, using 32-bit unsigned integers, with count taken…
A C service computes a buffer size as count multiplied by record size, using 32-bit unsigned integers, with count taken from user input. A very large count makes the product wrap around to a small number, a small buffer is allocated, and copying the records overflows the heap. What is the MOST direct fix?
- AAllocate a larger fixed-size buffer on the stack
- BCheck for multiplication overflow before allocating
- CRely on ASLR to prevent the overflow from happening
- DConfirm that the count value is above zero
Show the answer and explanation
Correct answer: B) Check for multiplication overflow before allocating
Integer overflow in size calculations leads to undersized allocations and memory corruption; checking arithmetic for overflow (or using safe arithmetic functions) before allocation fixes the root cause.
Why each option is right or wrong
- A) Incorrect. Any fixed size can still be exceeded by attacker input, and moving the buffer to the stack can create a stack overflow instead.
- B) Correct. Confirming that count is no greater than the maximum value divided by record size, or using checked or safe arithmetic, rejects inputs that would wrap around, so the allocation always matches the data copied.
- C) Incorrect. ASLR makes exploitation harder but does not prevent the memory corruption. It is a mitigation, not a fix for the flawed calculation.
- D) Incorrect. The variables are unsigned, so they can never be below zero, and a huge count passes this check easily. The danger is a very large value, which this check misses.
- Exam domain
- Software Development Security · 10% of CISSP
- Question type
- Multiple choice (one answer)
Related CISSP questions
- A team is designing password storage for a new web application. Which approach BEST protects stored passwords if the…Software Development Security
- A web application keeps the same session ID before and after login. An attacker plants a known session ID in a victim's…Software Development Security
- A research database allows only aggregate queries such as counts and averages.Software Development Security
- A web application connects to its database using the database owner account.Software Development Security
All 110 free CISSP questions by domain · 15 sample questions on one page
Practise the full CISSP exam
This question is one of a small free sample from the CertRidge CISSP bank. Full practice exams match the real exam's length, time limit and domain weights, explain every option, and Review Mode re-drills the questions you miss.
Original question written from the official exam guide. Not affiliated with ISC2; never copied from the real exam.