[PATCH] libwbclient clear pointer on bad read

Volker Lendecke Volker.Lendecke at SerNet.DE
Tue Jan 27 13:27:14 MST 2015


On Tue, Jan 27, 2015 at 09:26:06PM +0100, Stefan (metze) Metzmacher wrote:
> Am 27.01.2015 um 21:06 schrieb Volker Lendecke:
> > On Fri, Jan 23, 2015 at 12:45:50PM +0000, Matthew Newton wrote:
> >>   ... at end of usage:
> >>
> >>   wbcFreeContext(ctx);
> >>
> >> which would mean updating all the public functions in libwbclient
> >> to have an extra 'ctx' passed to them?
> >>
> >> The wbcContext would contain the fd, is_privileged, etc data, so
> >> all held in the calling process/thread.
> >>
> >> Or did you have something else in mind?
> > 
> > Not, that's pretty much what I had in mind. Although I'd not
> > change the existing functions but create a complete set of
> > new functions with some function name prefix/postfix. Not
> > sure about a good suggestion here. The existing functions
> > would refence one global context and mutex its use.
> 
> 
> Maybe
> 
> struct wbcContext *ctx = NULL;
> 
> ...
> 
> ctx = wbcCtxCreate();
> 
> ...
> 
> err = wbcCtxAuthenticateUserEx(ctx, &authparams, &info, &error);
> 
> ...
> 
> wbcCtxFree(ctx);
> 
> So the existing wbcExample() will become something like:
> 
> wbcErr wbcExample(void)
> {
> 	struct wbcContext *ctx = NULL;
> 	wbcErr wbc_status;
> 
>         ctx = wbcCtxGlobalLock();
> 
>         wbc_status = wbcCtxExample(ctx);
> 
>         wbcCtxGlobalUnlock(ctx);
> 
>         return wbc_status;
> }

Looks good to me from a naming perspective :-)

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de


More information about the samba-technical mailing list