qsort_r() (was: Re: ldb and strict overflow)

Timur I. Bakeyev timur at freebsd.org
Sat Mar 24 01:15:46 UTC 2018


On 24 March 2018 at 00:37, Andrew Bartlett via samba-technical <
samba-technical at lists.samba.org> 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/gary-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?
>

On unrelated note I want to remind everyone that at least for FreeBSD:

    The algorithms implemented by qsort(), qsort_r(), and heapsort() are
_not_
     stable, that is, if two members compare as equal, their order in the
     sorted array is undefined.

We've been bitten by this at least once. So something to keep in mind...

With regards,
Timur Bakeyev.


More information about the samba-technical mailing list