qsort_r() (was: Re: ldb and strict overflow)
asn at samba.org
Sat Mar 24 08:15:36 UTC 2018
On Saturday, 24 March 2018 00:37:50 CET Andrew Bartlett wrote:
> On Thu, 2018-03-22 at 07:31 +0100, Andreas Schneider wrote:
> > On Wednesday, 21 March 2018 22:54:02 CET Andrew Bartlett wrote:
> > > On Wed, 2018-03-21 at 19:41 +0100, Andreas Schneider wrote:
> > > > Attached is my current version. The ldb fixes don't work. I think this
> > > > code
> > > > needs unit tests and some rethinking. I need to dive into that
> > > > tomorrow.
> > >
> > > I wasn't able to find where the attempted ldb patches are, but I want
> > > to mention that you should be sure to check out
> > >
> > > http://git.catalyst.net.nz/gitweb?p=samba.git;a=shortlog;h=refs/heads/ga
> > > ry-l mdb-merged
> > Thanks, but I don't thing ldb_qsort is covered :-)
> > I'm talking about this code:
> > https://git.samba.org/?p=asn/
> > samba.git;a=commitdiff;h=f64281258f2a5a4c8f85004436ce430b01c9cea7
> > The patch is HACKISH and I need to write unit tests first and then fix it.
> Could we abandon it in favour of:
> void qsort_r(void *base, size_t nmemb, size_t size,
> int (*compar)(const void *, const void *, void *),
> void *arg);
> on GNU and BSD systems at least?
> Perhaps push it to lib/replace for the remaining systems?
> Andrew Bartlett
The way the algorithm is implemented isn't really bad, just the code would
need more tests and then some real cleanup. The libc qsort in various
implementations have issues so it would be better to improve this algorithm
and put it in a common place. However this function is public API, we can't
really remove it.
More information about the samba-technical