[PATCH] ndr: use resized array for ndr tokens

Andrew Bartlett abartlet at samba.org
Sat Feb 25 03:23:04 UTC 2017


On Sat, 2017-02-25 at 15:49 +1300, Douglas Bagnall wrote:
> I wrote:
> > OK, I see what you and Volker mean about talloc_array_length().
> > 
> > On 24/02/17 21:09, Stefan Metzmacher wrote:
> > > Hi Douglas,
> > > 
> > > I think if we want, we can keep that ABI.
> > > 
> > > We could change
> > > 
> > > struct ndr_token_list {
> > > 	struct ndr_token_list *prev, *next;
> > > };
> > > 
> > > into
> > > 
> > > struct ndr_token_list {
> > > 	struct ndr_token_list *array, *next_free;
> > > };
> > > 
> > > The 'count' can calculated as
> > > 
> > > if (list->next_free != NULL) {
> > > 	count = some pointer diff magic
> > > } else {
> > > 	count = talloc_array_length()
> > > }
> > 
> > Yes, though there would be some slightly horrible casting involved.
> 
> Like this. It's (arguably) not too bad. No pointer diff magic is
> needed because there is an unused uint32_t hanging around.

I really don't think that we should worry about changing the ABI here,
but certainly we should declare it.

If you want to try not to break the ABI we certainly shouldn't cast it
- just change the pointer type to struct ndr_token *, the structure
size stays the same.  No API user has any business poking into the NDR
tokens.

I'll note that the only user of libndr that I know of was openchange,
which is dead (openchange.org still down), and that always required a
rebuild for each Samba version anyway.  

Additionally please also note that I added a value to ndr_push for
Samba 4.5 and forgot to bump the ABI, and while nobody has complained
for that reason we 'owe' a major version bump anyway.

Thanks,

Andrew Bartlett

-- 
Andrew Bartlett                       http://samba.org/~abartlet/
Authentication Developer, Samba Team  http://samba.org
Samba Developer, Catalyst IT          http://catalyst.net.nz/services/samba




More information about the samba-technical mailing list