libselinux/backport-libselinux-restore-use-fixed-sized-integer-for-hash-index.patch
zgzxx 990a13251e backport upstream patches
(cherry picked from commit a7bf1057839c82d554d24c1220ddc1609098b96c)
2023-06-13 19:18:19 +08:00

67 lines
1.9 KiB
Diff

From 1609b9fdfddc1f6baa1b38b57018b16af9c5471a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
Date: Wed, 1 Feb 2023 11:55:10 +0100
Subject: [PATCH] libselinux: restore: use fixed sized integer for hash index
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The hash mask is set to 2^16 - 1, which does not fit into a signed 16
bit integer. Use uint32_t to be on the safe side. Also use size_t for
counting in debug function.
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: Jason Zaman <jason@perfinion.com>
Reference:https://github.com/SELinuxProject/selinux/commit/1609b9fdfddc1f6baa1b38b57018b16af9c5471a
Conflict:context adapt
---
libselinux/src/selinux_restorecon.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/selinux_restorecon.c b/src/selinux_restorecon.c
index 40a759f0..7ef2d45d 100644
--- a/src/selinux_restorecon.c
+++ b/src/selinux_restorecon.c
@@ -429,7 +429,8 @@ static int filespec_add(ino_t ino, const char *con, const char *file,
struct rest_flags *flags)
{
file_spec_t *prevfl, *fl;
- int h, ret;
+ uint32_t h;
+ int ret;
struct stat64 sb;
if (!fl_head) {
@@ -524,7 +525,8 @@ unlock_1:
static void filespec_eval(void)
{
file_spec_t *fl;
- int h, used, nel, len, longest;
+ uint32_t h;
+ size_t used, nel, len, longest;
if (!fl_head)
return;
@@ -544,7 +546,7 @@ static void filespec_eval(void)
}
selinux_log(SELINUX_INFO,
- "filespec hash table stats: %d elements, %d/%d buckets used, longest chain length %d\n",
+ "filespec hash table stats: %zu elements, %zu/%zu buckets used, longest chain length %zu\n",
nel, used, HASH_BUCKETS, longest);
}
#else
@@ -559,7 +561,7 @@ static void filespec_eval(void)
static void filespec_destroy(void)
{
file_spec_t *fl, *tmp;
- int h;
+ uint32_t h;
if (!fl_head)
return;
--
2.27.0