Repository navigation
Validate min_unit in bs_size_human_readable - #180
vojtechtrefny merged 1 commit into
Conversation
Only BS_BUNIT_UNDEF is normalized to bytes. Other values outside the binary unit range can index past b_units, including decimal units passed through the Python human_readable() wrapper. Treat unsupported values as B before scaling and indexing, preserving the existing UNDEF fallback. B remains the minimum unit, so larger sizes can still be promoted to other binary units. Add regression coverage for the range boundaries, invalid integer values and decimal unit names, with zero and signed sizes and both translation modes.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
Jenkins, ok to test. |
vojtechtrefny
left a comment
There was a problem hiding this comment.
Looks good to me, thank you.
bs_size_human_readable() only normalizes BS_BUNIT_UNDEF, allowing other unsupported min_unit values to index past b_units. This is also reachable through Python's human_readable("KB") and human_readable("MB"), since those names map to decimal unit values.
Normalize values outside B through YiB to B before scaling or indexing. This preserves valid binary units and the existing UNDEF fallback. B is the minimum unit, so automatic promotion to larger binary units still applies. Add regression coverage for integer boundaries and decimal unit names, including zero, positive and negative sizes with both translation settings.
Validated with GCC and Clang builds and make check, GCC make ci, and 60 native C API cases under ASan/UBSan. The new Python regressions crash against the original C implementation and pass with the fix. Three Python test executions per full suite were skipped because the required ps_AF.UTF-8 locale name is unavailable. Alpine/musl and csmock CI were not run locally
Summary by CodeRabbit