[PATCH] Various source3 fixes

Jeremy Allison jra at samba.org
Tue Apr 1 14:56:02 MDT 2014


On Tue, Apr 01, 2014 at 05:15:53PM +1300, Andrew Bartlett wrote:
> Date: Tue, 1 Apr 2014 17:03:34 +1300
> Subject: [PATCH 8/8] libsmbclient: Wrap more function calls in
>  talloc_stackframe() to protect against talloc_tos() calls
> 
> BUG: https://bugzilla.samba.org/show_bug.cgi?id=8449
> Change-Id: I338aead708f1f42649dcfb37d4385924bb3485ea
> Signed-off-by: Andrew Bartlett <abartlet at samba.org>
> ---
>  source3/libsmb/libsmb_context.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c
> index c2b88f5..77658ec 100644
> --- a/source3/libsmb/libsmb_context.c
> +++ b/source3/libsmb/libsmb_context.c
> @@ -560,6 +560,7 @@ SMBCCTX *
>  smbc_init_context(SMBCCTX *context)
>  {
>          int pid;
> +        TALLOC_CTX *frame;
>  
>          if (!context) {
>                  errno = EBADF;
> @@ -571,12 +572,15 @@ smbc_init_context(SMBCCTX *context)
>                  return NULL;
>          }
>  
> +        frame = talloc_stackframe();
> +
>          if ((!smbc_getFunctionAuthData(context) &&
>               !smbc_getFunctionAuthDataWithContext(context)) ||
>              smbc_getDebug(context) < 0 ||
>              smbc_getDebug(context) > 100) {
>  
>                  errno = EINVAL;
> +                TALLOC_FREE(frame);

Here's a version of this patch that does the TALLOC_FREE's
before setting the errno's (just in case
talloc_free sets errno at some point. I
don't think it does right now but it's
better to be safe).

Let me know if it's ok and I'll push.

Cheers,

	Jeremy.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-libsmbclient-Wrap-more-function-calls-in-talloc_stac.patch
Type: text/x-diff
Size: 4223 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20140401/543841f9/attachment.patch>


More information about the samba-technical mailing list