Blame SOURCES/0186-sd-bus-call-cap_last_cap-only-once-in-has_cap.patch

a3e2b5
From 770b16b22dd0eec04fd1493dae644206c32f8e04 Mon Sep 17 00:00:00 2001
a3e2b5
From: Lennart Poettering <lennart@poettering.net>
a3e2b5
Date: Wed, 10 Oct 2018 11:12:54 +0200
a3e2b5
Subject: [PATCH] sd-bus: call cap_last_cap() only once in has_cap()
a3e2b5
a3e2b5
Also, use the same type everywhere for dealing with it.
a3e2b5
a3e2b5
(cherry picked from commit 92a40e20bf970c3ded8a50fbeeae882a7b970c9a)
a3e2b5
a3e2b5
Resolves: #1683319
a3e2b5
---
a3e2b5
 src/libsystemd/sd-bus/bus-creds.c | 7 +++++--
a3e2b5
 1 file changed, 5 insertions(+), 2 deletions(-)
a3e2b5
a3e2b5
diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c
a3e2b5
index 6896bcf246..2a47c68ffc 100644
a3e2b5
--- a/src/libsystemd/sd-bus/bus-creds.c
a3e2b5
+++ b/src/libsystemd/sd-bus/bus-creds.c
a3e2b5
@@ -652,16 +652,19 @@ _public_ int sd_bus_creds_get_description(sd_bus_creds *c, const char **ret) {
a3e2b5
 }
a3e2b5
 
a3e2b5
 static int has_cap(sd_bus_creds *c, size_t offset, int capability) {
a3e2b5
+        unsigned long lc;
a3e2b5
         size_t sz;
a3e2b5
 
a3e2b5
         assert(c);
a3e2b5
         assert(capability >= 0);
a3e2b5
         assert(c->capability);
a3e2b5
 
a3e2b5
-        if ((unsigned) capability > cap_last_cap())
a3e2b5
+        lc = cap_last_cap();
a3e2b5
+
a3e2b5
+        if ((unsigned long) capability > lc)
a3e2b5
                 return 0;
a3e2b5
 
a3e2b5
-        sz = DIV_ROUND_UP(cap_last_cap(), 32U);
a3e2b5
+        sz = DIV_ROUND_UP(lc, 32LU);
a3e2b5
 
a3e2b5
         return !!(c->capability[offset * sz + CAP_TO_INDEX((uint32_t) capability)] & CAP_TO_MASK_CORRECTED((uint32_t) capability));
a3e2b5
 }