Re: [bug #63605] Large number of UBSAN failures in test suite

James Youngman <[email protected]>
Newsgroups gmane.comp.gnu.findutils.bugs
Message-ID <CAGwX764Cf93Fq=YQaaGVh12Z7VZVvQZq9ggmrNRz4uAKG8XN3Q@mail.gmail.com>
Fixed with the attached patch.


On Sun, May 19, 2024 at 10:26 PM James Youngman <[email protected]>
wrote:

> Update of bug #63605 (group findutils):
>
>                   Status:                    None => Fixed
>
>              Assigned to:                    None => jay
>
>
>     _______________________________________________________
>
> Follow-up Comment #1:
>
> This problem is fixed in the git code for findutils.
> To resolve your problem, you could either wait for the
> next official release of findutils, or check out a copy
> of the code from the git repository for findutils.
>
> See https://savannah.gnu.org/git/?group=findutils
>
>
>
>     _______________________________________________________
>
> Reply to this item at:
>
>   <https://savannah.gnu.org/bugs/?63605>
>
> _______________________________________________
> Message sent via Savannah
> https://savannah.gnu.org/
>
>
0001-find-avoid-undefined-behaviour-in-consider_arm_swap.patch (text/x-patch, 1.2 KB)
From 9874c773f2f15ef81c7d95eb0b08f0245acd87b3 Mon Sep 17 00:00:00 2001
From: James Youngman <[email protected]>
Date: Sun, 19 May 2024 22:23:19 +0100
Subject: [PATCH] [find] avoid undefined behaviour in consider_arm_swap.
To: [email protected]

This fixes Savannah bug #63605.

* find/tree.c: avoid invalid struct member access in consider_arm_swap
---
 find/tree.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/find/tree.c b/find/tree.c
index 1c6b4588..c42eb9e0 100644
--- a/find/tree.c
+++ b/find/tree.c
@@ -529,7 +529,7 @@ consider_arm_swap (struct predicate *p)
 {
   int left_cost, right_cost;
   const char *reason = NULL;
-  struct predicate **pl, **pr;
+  struct predicate **pl = NULL, **pr = NULL;
 
   if (BI_OP != p->p_type)
     reason = "Not a binary operation";
@@ -540,14 +540,18 @@ consider_arm_swap (struct predicate *p)
 	reason = "Doesn't have two arms";
     }
 
-
   if (!reason)
     {
       if (NULL == p->pred_left->pred_right)
-	reason = "Left arm has no child on RHS";
+	{
+	  reason = "Left arm has no child on RHS";
+	}
+      else
+	{
+	  pr = &p->pred_right;
+	  pl = &p->pred_left->pred_right;
+	}
     }
-  pr = &p->pred_right;
-  pl = &p->pred_left->pred_right;
 
   if (!reason)
     {
-- 
2.39.2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.