elf: Fix incorrect comparison in sort_priorities_by_name

Message ID 87360e6dp2.fsf@oldenburg2.str.redhat.com
State Committed
Commit 0d4ed9d40efa84e8dc88e64cf337c8e95af7b045
Headers
Series elf: Fix incorrect comparison in sort_priorities_by_name |

Commit Message

Florian Weimer Dec. 9, 2020, 6:23 p.m. UTC
  Reported-By: Stefan Liebler <stli@linux.ibm.com>

---
 elf/dl-hwcaps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

H.J. Lu Dec. 9, 2020, 6:29 p.m. UTC | #1
On Wed, Dec 9, 2020 at 10:24 AM Florian Weimer via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> Reported-By: Stefan Liebler <stli@linux.ibm.com>
>
> ---
>  elf/dl-hwcaps.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/elf/dl-hwcaps.c b/elf/dl-hwcaps.c
> index 5a71f80154..000e3c0eb9 100644
> --- a/elf/dl-hwcaps.c
> +++ b/elf/dl-hwcaps.c
> @@ -153,7 +153,7 @@ sort_priorities_by_name (void)
>         else
>           to_compare = previous->name_length;
>         int cmp = memcmp (current->name, previous->name, to_compare);
> -       if (cmp >= 0
> +       if (cmp > 0
>             || (cmp == 0 && current->name_length >= previous->name_length))
>           break;
>
>

LGTM.
  

Patch

diff --git a/elf/dl-hwcaps.c b/elf/dl-hwcaps.c
index 5a71f80154..000e3c0eb9 100644
--- a/elf/dl-hwcaps.c
+++ b/elf/dl-hwcaps.c
@@ -153,7 +153,7 @@  sort_priorities_by_name (void)
 	else
 	  to_compare = previous->name_length;
 	int cmp = memcmp (current->name, previous->name, to_compare);
-	if (cmp >= 0
+	if (cmp > 0
 	    || (cmp == 0 && current->name_length >= previous->name_length))
 	  break;