[PATCH] libsmb: fix leak in opendir error path

Jeremy Allison jra at samba.org
Tue Oct 25 16:51:55 UTC 2016


On Tue, Oct 25, 2016 at 06:25:02PM +0200, David Disseldorp wrote:
> Fixes CID 242325 - dir state and the talloc frame are leaked on
> user_auth_info_init() failure.

Good catch - obvious fix ! Pushed, thanks.

> Signed-off-by: David Disseldorp <ddiss at samba.org>
> ---
>  source3/libsmb/libsmb_dir.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c
> index dd37a24..8bf3c6b 100644
> --- a/source3/libsmb/libsmb_dir.c
> +++ b/source3/libsmb/libsmb_dir.c
> @@ -485,6 +485,12 @@ SMBC_opendir_ctx(SMBCCTX *context,
>  
>  		u_info = user_auth_info_init(frame);
>  		if (u_info == NULL) {
> +			if (dir) {
> +				SAFE_FREE(dir->fname);
> +				SAFE_FREE(dir);
> +			}
> +			TALLOC_FREE(frame);
> +			errno = ENOMEM;
>  			return NULL;
>  		}
>  		set_cmdline_auth_info_username(u_info, user);
> -- 
> 2.1.4
> 
> 



More information about the samba-technical mailing list