]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Fix CID 1504457 Resource leak
authorVolker Lendecke <vl@samba.org>
Fri, 20 May 2022 08:18:59 +0000 (10:18 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 6 Jun 2022 19:22:28 +0000 (19:22 +0000)
Highly likely that's a false positive because Coverity does not
understand that srv_encrypt_buffer() only allocates when
NT_STATUS_OK(status), but it does not hurt to make it happy this way.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/smb1_process.c

index c041b48d88d07cc32f1a845e156eb7a173460db1..140884adb96b2bbca9dc2faf7674c91a9cd24891 100644 (file)
@@ -238,14 +238,17 @@ bool smb1_srv_send(struct smbXsrv_connection *xconn, char *buffer,
        }
 
        if (do_encrypt) {
-               NTSTATUS status = srv_encrypt_buffer(xconn, buffer, &buf_out);
+               char *enc = NULL;
+               NTSTATUS status = srv_encrypt_buffer(xconn, buffer, &enc);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(0, ("send_smb: SMB encryption failed "
                                "on outgoing packet! Error %s\n",
                                nt_errstr(status) ));
+                       SAFE_FREE(enc);
                        ret = -1;
                        goto out;
                }
+               buf_out = enc;
        }
 
        len = smb_len_large(buf_out) + 4;