From: nmordech@redhat.com Date: Tue, 12 Mar 2024 06:36:29 +0000 (+0000) Subject: cls/cas/cls_cas_internal: Initialize 'hash' value before decoding into it X-Git-Tag: v17.2.8~61^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=db0740400d203da0c468175d2a38df299a23aa3a;p=ceph.git cls/cas/cls_cas_internal: Initialize 'hash' value before decoding into it 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 (cherry picked from commit cffcec35c5760ab9142dca06182d42900e247a3c) --- diff --git a/src/cls/cas/cls_cas_internal.h b/src/cls/cas/cls_cas_internal.h index 09e7f9f1f69d3..bedacd66f5d15 100644 --- a/src/cls/cas/cls_cas_internal.h +++ b/src/cls/cas/cls_cas_internal.h @@ -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);