Re: [PATCH 1/3] libsepol: ensure transitivity in compare functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 22, 2024 at 10:14 AM James Carter <jwcart2@xxxxxxxxx> wrote:
>
> On Wed, Jan 31, 2024 at 8:06 AM Christian Göttsche
> <cgzones@xxxxxxxxxxxxxx> wrote:
> >
> > Ensure comparison functions used by qsort(3) fulfill transitivity, since
> > otherwise the resulting array might not be sorted correctly or worse[1]
> > in case of integer overflows.
> >
> > [1]: https://www.qualys.com/2024/01/30/qsort.txt
> >
> > Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx>
>
> For these three patches:
> Acked-by: James Carter <jwcart2@xxxxxxxxx>
>
These three patches have been merged.
Thanks,
Jim

> > ---
> >  libsepol/src/kernel_to_common.c | 2 +-
> >  libsepol/src/module_to_cil.c    | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/libsepol/src/kernel_to_common.c b/libsepol/src/kernel_to_common.c
> > index 2422eed0..44f0be23 100644
> > --- a/libsepol/src/kernel_to_common.c
> > +++ b/libsepol/src/kernel_to_common.c
> > @@ -503,7 +503,7 @@ static int ibendport_data_cmp(const void *a, const void *b)
> >         if (rc)
> >                 return rc;
> >
> > -       return (*aa)->u.ibendport.port - (*bb)->u.ibendport.port;
> > +       return spaceship_cmp((*aa)->u.ibendport.port, (*bb)->u.ibendport.port);
> >  }
> >
> >  static int pirq_data_cmp(const void *a, const void *b)
> > diff --git a/libsepol/src/module_to_cil.c b/libsepol/src/module_to_cil.c
> > index ee22dbbd..c8dae562 100644
> > --- a/libsepol/src/module_to_cil.c
> > +++ b/libsepol/src/module_to_cil.c
> > @@ -1680,7 +1680,7 @@ static int class_perm_cmp(const void *a, const void *b)
> >         const struct class_perm_datum *aa = a;
> >         const struct class_perm_datum *bb = b;
> >
> > -       return aa->val - bb->val;
> > +       return spaceship_cmp(aa->val, bb->val);
> >  }
> >
> >  static int common_to_cil(char *key, void *data, void *UNUSED(arg))
> > --
> > 2.43.0
> >
> >





[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux