CompTIA

CAS-005 practice question 18

CompTIA SecurityX · free question 18 of 20

Question

A security technician is investigating a system that tracks inventory via a batch update each night. The technician is concerned that the system poses a risk to the business, as errors are occasionally generated and reported inventory appears incorrect. The following output log is provided: ``` Starting Boxes = 20 Transaction Operation Running total 1 + 10 30 2 + 30 50 3 + 10 60 4 - 10 50 5 - 40 (Below zero balance!) -10 6 + 30 20 7 + 10 60 8 + 40 60 ``` The technician reviews the output of the batch job and discovers that the inventory was never less than zero, and the final inventory was 100 rather than 60. Which of the following should the technician do to resolve this issue?
  • A. Ensure that the application is using memory-safe functions to prevent integer overflows.
  • B. Recommend thread-safe processes in the code to eliminate race conditions. Correct
  • C. Require the developers to include exception handlers to accommodate out-of-bounds results.
  • D. Move the batch processing from client side to server side to remove client processing inconsistencies.

Explanation

The running totals do not follow from the operations (for example, 20 + 30 is reported as 50 and 20 + 10 as 60), which shows several transactions reading and writing the shared total at the same time and overwriting each other's results. That is a race condition, fixed by making the updates thread-safe with synchronization or locking around the critical section. The values are small, so there is no integer overflow, and exception handlers or moving processing to the server would not stop concurrent updates from corrupting the total.

Practice the whole free set

Answer all 20 free CAS-005 questions with instant feedback, or unlock all 426 questions with Learn and Exam modes.