From 2b1ef2d894a30648295186ad755affb0032d5581 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Mon, 21 Oct 2024 12:48:19 +0200 Subject: [PATCH] libcli/smb: rely on the caller zero-initializing "lease" in smb2_lease_pull() Doing the zero initialization per struct member just feels like a way for bugs to creep in, even when leasev1 is not going to change ever. The only caller has already zero-initialized state->lease twice via 1) __tevent_req_create() and 2) a struct initializer of "state". Signed-off-by: Ralph Boehme Reviewed-by: Stefan Metzmacher --- libcli/smb/smb2_lease.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libcli/smb/smb2_lease.c b/libcli/smb/smb2_lease.c index fc641ff7c99..d3d6a4926b9 100644 --- a/libcli/smb/smb2_lease.c +++ b/libcli/smb/smb2_lease.c @@ -23,6 +23,11 @@ #include "includes.h" #include "../libcli/smb/smb_common.h" +/** + * Pull a lease off the wire into a struct smb2_lease. + * + * Note: the caller MUST zero initialize "lease". + **/ ssize_t smb2_lease_pull(const uint8_t *buf, size_t len, struct smb2_lease *lease) { @@ -47,8 +52,6 @@ ssize_t smb2_lease_pull(const uint8_t *buf, size_t len, switch (version) { case 1: - ZERO_STRUCT(lease->parent_lease_key); - lease->lease_epoch = 0; break; case 2: memcpy(&lease->parent_lease_key, buf+32, 16);