]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli/smb: rely on the caller zero-initializing "lease" in smb2_lease_pull()
authorRalph Boehme <slow@samba.org>
Mon, 21 Oct 2024 10:48:19 +0000 (12:48 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 5 Nov 2024 14:39:30 +0000 (14:39 +0000)
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 <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
libcli/smb/smb2_lease.c

index fc641ff7c99edb12de9054f56a406f7c07eaa20d..d3d6a4926b929e3f61a8a5d1e8cb22b64cded101 100644 (file)
 #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);