1 Star 0 Fork 49

YYNA/systemd

forked from src-anolis-os/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0186-sd-bus-call-cap_last_cap-only-once-in-has_cap.patch 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
张彬琛 提交于 2021-01-20 13:59 . import systemd-239-29.el8.src.rpm
From 770b16b22dd0eec04fd1493dae644206c32f8e04 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Wed, 10 Oct 2018 11:12:54 +0200
Subject: [PATCH] sd-bus: call cap_last_cap() only once in has_cap()
Also, use the same type everywhere for dealing with it.
(cherry picked from commit 92a40e20bf970c3ded8a50fbeeae882a7b970c9a)
Resolves: #1683319
---
src/libsystemd/sd-bus/bus-creds.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c
index 6896bcf246..2a47c68ffc 100644
--- a/src/libsystemd/sd-bus/bus-creds.c
+++ b/src/libsystemd/sd-bus/bus-creds.c
@@ -652,16 +652,19 @@ _public_ int sd_bus_creds_get_description(sd_bus_creds *c, const char **ret) {
}
static int has_cap(sd_bus_creds *c, size_t offset, int capability) {
+ unsigned long lc;
size_t sz;
assert(c);
assert(capability >= 0);
assert(c->capability);
- if ((unsigned) capability > cap_last_cap())
+ lc = cap_last_cap();
+
+ if ((unsigned long) capability > lc)
return 0;
- sz = DIV_ROUND_UP(cap_last_cap(), 32U);
+ sz = DIV_ROUND_UP(lc, 32LU);
return !!(c->capability[offset * sz + CAP_TO_INDEX((uint32_t) capability)] & CAP_TO_MASK_CORRECTED((uint32_t) capability));
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ful9/systemd.git
git@gitee.com:ful9/systemd.git
ful9
systemd
systemd
a8

搜索帮助

0d507c66 1850385 C8b1a773 1850385