From: Volker Lendecke Date: Fri, 20 May 2022 08:18:59 +0000 (+0200) Subject: smbd: Fix CID 1504457 Resource leak X-Git-Tag: talloc-2.3.4~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a395f752f0748751d4ade533c41066903f26c2dd;p=thirdparty%2Fsamba.git smbd: Fix CID 1504457 Resource leak 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 Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/smb1_process.c b/source3/smbd/smb1_process.c index c041b48d88d..140884adb96 100644 --- a/source3/smbd/smb1_process.c +++ b/source3/smbd/smb1_process.c @@ -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;