[PATCH] Fix new Coverity IDs

Andreas Schneider asn at samba.org
Thu Jan 12 10:33:30 UTC 2017


On Thursday, 12 January 2017 08:45:58 CET Stefan Metzmacher wrote:
> Hi Jeremy,
> 
> >>> - which uses null_context - which can change what it returns
> >>> if someone ever calls talloc_enable_null_tracking() !!!!!
> >> 
> >> Never mind. As Volker just pointed out to me on the phone,
> >> null_context = _talloc_named_const(NULL, 0, "null_context"),
> >> which will always return zero size anyway. Still,
> >> that code shouldn't be in talloc_get_size().
> >> 
> >> Patch(es) to follow !
> > 
> > Here the are. Please review and push if happy !
> > 
> > (Finally fixed the to: address for metze, sorry).
> 
> The talloc_get_size() change is ok.
> 
> For the others please use
> 
> if (prids != NULL) {
> 	*prids = NULL;
> }
> 
> at the beginning and
> 
> if (prids != NULL) {
> 	*prids = rids;
> }
> 
> at the end or
> 
> *prids = NULL
> 
> at the beginning and
> 
> *prids = rids;
> 
> at the end.
> 
> But doing just
> 
> if (prids) {
> 	*prids = rids;
> }
> 
> is ugly and you're the one who always preach
> that we should not leave pointers uninitialized,
> so I think we should always set it to NULL at the
> beginning.
> 
> metze


uint32_t *rids;


needs to be initialized with NULL!

uint32_t *rids = NULL;

or the TALLOC_FREE() in 'done' might crash! Which just happend here!


/home/asn/workspace/projects/samba/bin/winbindd: #5  0x00005647671a8c91 in 
sam_query_user_list (domain=0x56476795ee60, mem_ctx=0x5647679537b0, 
prids=0x7ffda8e5f788) at ../source3/winbindd/winbindd_$
amr.c:211
/home/asn/workspace/projects/samba/bin/winbindd:         samr_pipe = 
0x564767976d70
/home/asn/workspace/projects/samba/bin/winbindd:         dom_pol = 
{handle_type = 0, uuid = {time_low = 0, time_mid = 0, time_hi_and_version = 0, 
clock_seq = "\000", node = "\000\000\000\000\000"}}
/home/asn/workspace/projects/samba/bin/winbindd:         rids = 0x56476795ee78
/home/asn/workspace/projects/samba/bin/winbindd:         tmp_ctx = 
0x56476795a480
/home/asn/workspace/projects/samba/bin/winbindd:         status = {v = 
3221225695}
/home/asn/workspace/projects/samba/bin/winbindd:         result = {v = 
2833643200}
/home/asn/workspace/projects/samba/bin/winbindd:         b = 0x0
/home/asn/workspace/projects/samba/bin/winbindd:         __FUNCTION__ = 
"sam_query_user_list"







-- 
Andreas Schneider                   GPG-ID: CC014E3D
Samba Team                             asn at samba.org
www.samba.org



More information about the samba-technical mailing list