]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/cas/cls_cas_internal: Initialize 'hash' value before decoding into it 56136/head
authornmordech@redhat.com <nmordech@redhat.com>
Tue, 12 Mar 2024 06:36:29 +0000 (06:36 +0000)
committernmordech@redhat.com <nmordech@redhat.com>
Tue, 12 Mar 2024 09:25:49 +0000 (09:25 +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>
src/cls/cas/cls_cas_internal.h

index 037e60fffd9da0929d551b3ccdf6606d7262254a..0b5c56977d29cfce167c6ef22448daeb718eb94e 100644 (file)
@@ -244,7 +244,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);