✗ ci.openvz.org: failure for Fix UB in choose_service_fd_base due to calling __builtin_clz(0)

Submitted by Radoslaw Burny on April 9, 2018, 3:33 p.m.

Details

Message ID CAFkxGoPXL3q6RbPZgvUVD-RMXzaqonq_6amHD73g65DQ_jjiXg@mail.gmail.com
State New
Series "Fix UB in choose_service_fd_base due to calling __builtin_clz(0)"
Headers show

Commit Message

Radoslaw Burny April 9, 2018, 3:33 p.m.
Sorry, I somehow messed up linebreaks in the original patch. Here's the
fixed one.





From: Radoslaw Burny <rburny at google.com>

Subject: [PATCH] Fix UB in choose_service_fd_base.

Signed-off-by: Radoslaw Burny <rburny at google.com>

---
 criu/util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

                /* Right border is bigger, than rlim. OK, then just aligned
value is enough */

Patch hide | download patch | download mbox

diff --git a/criu/util.c b/criu/util.c
index b19bf517..48ba09a8 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -588,9 +588,9 @@  static int choose_service_fd_base(struct pstree_item
*me)
        nr += 16; /* Safety pad */
        real_nr = nr;

-       nr /= (1024 / sizeof(void *));
+       /* Align nr to the power of 2 for easier debugging */
+       BUG_ON(nr <= 0);
        nr = 1 << (32 - __builtin_clz(nr));
-       nr *= (1024 / sizeof(void *));

        if (nr > service_fd_rlim_cur) {