]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/cas/cls_cas_internal: Initialize 'hash' value before decoding into it 59236/head
authornmordech@redhat.com <nmordech@redhat.com>
Tue, 12 Mar 2024 06:36:29 +0000 (06:36 +0000)
committerNitzan Mordechai <nmordech@redhat.com>
Thu, 15 Aug 2024 08:47:32 +0000 (08:47 +0000)
In the decode function for chunk_refs_by_hash_t, initialize the variable
'hash' of type ceph_le32 to zero before its first use.
This prevents the variable from containing dirty (uninitialized) values,
which could lead to unexpected behavior later in the code.

Fixes: https://tracker.ceph.com/issues/64854
Signed-off-by: Nitzan Mordechai <nmordech@redhat.com>
(cherry picked from commit cffcec35c5760ab9142dca06182d42900e247a3c)

src/cls/cas/cls_cas_internal.h

index 09e7f9f1f69d345dc89d8cdb0b652574364676b9..bedacd66f5d157a4584255ab1ace1419397ec2be 100644 (file)
@@ -238,7 +238,7 @@ struct chunk_refs_by_hash_t : public chunk_refs_t::refs_t {
     int hash_bytes = (hash_bits + 7) / 8;
     while (n--) {
       int64_t poolid;
-      ceph_le32 hash;
+      ceph_le32 hash{0};
       uint64_t count;
       denc_signed_varint(poolid, p);
       memcpy(&hash, p.get_pos_add(hash_bytes), hash_bytes);