Security Operations
A coupon endpoint reads a database flag, then sets it to used in a separate statement. Two simultaneous requests redeem the same one-time coupon. Which change fixes this by making the check and update one indivisible step?
Show the answer
Correct answerB. Atomic check-and-set operation
AWhy not this: Validating the code's format does not stop two valid requests from racing on the flag.
BWhy this is right: An atomic conditional update lets only one request succeed, because no other can run between check and set.
CWhy not this: Code signing proves software integrity and has no effect on concurrent access to data.
DWhy not this: Memory-safe functions prevent buffer errors and do nothing about interleaved requests.
An atomic check-and-set (for example a single conditional update) completes as one indivisible operation, so no second request can slip between the check and the update. Input validation checks the coupon's format but cannot close the race between two valid requests.