fix: guard SDS buffer free-space calculation against invalid count state#224
Conversation
Automated security fix generated by OrbisAI Security
|
SDS-Framework/sds/sds_buffer.c Lines 181 to 186 in 7bc88c3 num is limited to either requested buf_size or number of available bytes cnt_free so that statement does not hold.
|
|
Thanks for reviewing. I agree with your point that under the normal ring-buffer invariant, The intended change is narrower: it hardens the free-space calculation against a broken/corrupted invariant where I’m happy to reframe this PR as defensive robustness rather than a critical vulnerability, for example:
And update the description to remove the “critical”/heap-overflow wording unless there is a reachable path that violates the ring-buffer invariant. |
Summary
This change hardens
sdsBufferWrite()by ensuringcnt_freeis clamped to0whencnt_usedis greater than or equal to the configured buffer size.Under normal operation,
numis already limited to the available free space before thememcpycalls. This patch is therefore intended as defensive robustness against an invalid/corrupted counter state, not as a confirmed, directly reachable heap overflow.Changes
sds/sds_buffer.cVerification
Automated security fix by OrbisAI Security