]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
common/io_exerciser: fix buffer overread in DataGenerator 64036/head
authorKefu Chai <tchaikov@gmail.com>
Thu, 19 Jun 2025 08:19:04 +0000 (16:19 +0800)
committerKefu Chai <tchaikov@gmail.com>
Thu, 19 Jun 2025 08:48:21 +0000 (16:48 +0800)
commit0c66b1c5b526373ea6aad421adeb18700647c8a4
treea7e3babe73aa453a8e5e9d2b896ec8e5edd97133
parent0c95e42ecfe46e4d35777dbe0fb23cbc00804eb3
common/io_exerciser: fix buffer overread in DataGenerator

Fix GCC-15 warning about reading uninitialized memory when copying
random data to fill remaining bytes in generated blocks.

The issue occurred when remainingBytes exceeded the 8-byte size of
the uint64_t rand1 variable, causing memcpy to read beyond the
variable's boundary. While this didn't cause crashes (reading from
stack) and the buffer was still properly filled with rand2, it
violated memory safety and generated compiler warnings.

Fixed by limiting the copy size to the actual size of the source
variable (sizeof(rand1)) to ensure we only read initialized memory.

Resolves GCC-15 warnings:

- DataGenerator.cc:76: memcpy reading 9-15 bytes from 8-byte region
- DataGenerator.cc:108: memcpy reading 9-15 bytes from 8-byte region

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/common/io_exerciser/DataGenerator.cc