From: Ronen Friedman Date: Mon, 2 Mar 2026 17:51:09 +0000 (+0200) Subject: osd/scrub: extract_crc_from_bufferlist: fix off-by-1 error X-Git-Tag: testing/wip-vshankar-testing-20260304.135307~16^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2b2c07b03978edaa6d56ef52f92cba62cdd831b4;p=ceph-ci.git osd/scrub: extract_crc_from_bufferlist: fix off-by-1 error Fixes: https://tracker.ceph.com/issues/75270 Signed-off-by: Ronen Friedman --- diff --git a/src/osd/scrubber/scrub_backend.cc b/src/osd/scrubber/scrub_backend.cc index 47b36acea65..47bb49a5f6f 100644 --- a/src/osd/scrubber/scrub_backend.cc +++ b/src/osd/scrubber/scrub_backend.cc @@ -127,13 +127,13 @@ std::string ScrubBackend::extract_crcs_from_map( } std::string ScrubBackend::extract_crc_from_bufferlist( - const bufferlist& crc_buffer) { - std::string crc_string; - constexpr size_t digest_length = sizeof(uint32_t); - for (size_t i = 0; i < digest_length; i++) { - crc_string += fmt::format("{:02x}", crc_buffer[digest_length - i]); - } - return crc_string; + const bufferlist& crc_buffer) +{ + // assuming the CRC is uint32_b, and that we have 8 bits per byte. + // also assuming little-endian storage of the digest in the bufferlist + return fmt::format( + "{:02x}{:02x}{:02x}{:02x}", crc_buffer[3], crc_buffer[2], crc_buffer[1], + crc_buffer[0]); } uint64_t ScrubBackend::logical_to_ondisk_size(uint64_t logical_size,