Skip to main content

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)

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.