libsepol/backport-libsepol-check-correct-pointer-for-oom.patch

35 lines
1.3 KiB
Diff
Raw Normal View History

2022-11-21 14:16:32 +08:00
From 68a29c3aee60a6dd4e0d435fc10adb0f2cc1c0ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
Date: Fri, 8 Apr 2022 15:10:51 +0200
Subject: [PATCH] libsepol: check correct pointer for oom
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Check the actual pointer which memory was assigned to, not its parent
array pointer.
services.c:810:14: warning: Assigned value is garbage or undefined [core.uninitialized.Assign]
**r_buf = **new_buf;
^ ~~~~~~~~~
Acked-by: James Carter <jwcart2@gmail.com>
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
libsepol/src/services.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libsepol/src/services.c b/libsepol/src/services.c
index 47e564df4..d7510e9da 100644
--- a/libsepol/src/services.c
+++ b/libsepol/src/services.c
@@ -803,7 +803,7 @@ static int constraint_expr_eval_reason(context_struct_t *scontext,
if (len < 0 || len >= reason_buf_len - reason_buf_used) {
new_buf_len = reason_buf_len + REASON_BUF_SIZE;
*new_buf = realloc(*r_buf, new_buf_len);
- if (!new_buf) {
+ if (!*new_buf) {
ERR(NULL, "failed to realloc reason buffer");
goto out1;
}