[iobuf] Improve robustness of I/O buffer allocation
authorMichael Brown <mcb30@ipxe.org>
Thu, 11 Feb 2016 18:44:24 +0000 (18:44 +0000)
committerMichael Brown <mcb30@ipxe.org>
Thu, 11 Feb 2016 19:04:23 +0000 (19:04 +0000)
commit12b3b578869d5c25a32edd81950e104a286643d7
treea6c9250db7e8986c130c91a67cab4f3d74258db2
parente2b1140486e6d5da756d64ae5fc051b79664c6d6
[iobuf] Improve robustness of I/O buffer allocation

Guard against various corner cases (such as zero-length buffers, zero
alignments, and integer overflow when rounding up allocation lengths
and alignments) and ensure that the struct io_buffer is correctly
aligned even when the caller requests a non-zero alignment for the I/O
buffer itself.

Add self-tests to verify that the resulting alignments and lengths are
correct for a range of allocations.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/iobuf.c
src/tests/iobuf_test.c [new file with mode: 0644]
src/tests/tests.c