]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd/scrub: extract_crc_from_bufferlist: fix off-by-1 error
authorRonen Friedman <rfriedma@redhat.com>
Mon, 2 Mar 2026 17:51:09 +0000 (19:51 +0200)
committerRonen Friedman <rfriedma@redhat.com>
Tue, 3 Mar 2026 11:57:03 +0000 (13:57 +0200)
Fixes: https://tracker.ceph.com/issues/75270
Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
src/osd/scrubber/scrub_backend.cc

index 47b36acea65edec488d15b7189efe5a9bf11b6e3..47bb49a5f6ffdd1feb56729f5b044915496032f0 100644 (file)
@@ -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,