From: <luhuaxin1@huawei.com>
To: <selinux@vger.kernel.org>
Cc: <fangxiuning@huawei.com>, <zhujianwei7@huawei.com>,
<shenyining@huawei.com>, Huaxin Lu <luhuaxin1@huawei.com>
Subject: [PATCH v1] libsepol: add check for category value before printing
Date: Tue, 14 Nov 2023 07:27:50 +0800 [thread overview]
Message-ID: <20231113232750.48706-1-luhuaxin1@huawei.com> (raw)
From: Huaxin Lu <luhuaxin1@huawei.com>
In mls_semantic_level_expand(), there is a explicitly determine
whether category is 0, which may cause an potential integer
overflow in error branch.
Signed-off-by: Huaxin Lu <luhuaxin1@huawei.com>
---
libsepol/src/expand.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libsepol/src/expand.c b/libsepol/src/expand.c
index ee5f9185..9ed22bfd 100644
--- a/libsepol/src/expand.c
+++ b/libsepol/src/expand.c
@@ -945,8 +945,8 @@ int mls_semantic_level_expand(mls_semantic_level_t * sl, mls_level_t * l,
for (cat = sl->cat; cat; cat = cat->next) {
if (!cat->low || cat->low > cat->high) {
ERR(h, "Category range is not valid %s.%s",
- p->p_cat_val_to_name[cat->low - 1],
- p->p_cat_val_to_name[cat->high - 1]);
+ cat->low > 0 ? p->p_cat_val_to_name[cat->low - 1] : "n/a",
+ cat->high > 0 ? p->p_cat_val_to_name[cat->high - 1] : "n/a");
return -1;
}
for (i = cat->low - 1; i < cat->high; i++) {
--
2.33.0
next reply other threads:[~2023-11-14 1:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-13 23:27 luhuaxin1 [this message]
2023-11-14 20:39 ` [PATCH v1] libsepol: add check for category value before printing James Carter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231113232750.48706-1-luhuaxin1@huawei.com \
--to=luhuaxin1@huawei.com \
--cc=fangxiuning@huawei.com \
--cc=selinux@vger.kernel.org \
--cc=shenyining@huawei.com \
--cc=zhujianwei7@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).