All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian Göttsche" <cgzones@googlemail.com>
To: selinux@vger.kernel.org
Subject: [PATCH v2] libselinux: restorecon: avoid printing NULL pointer
Date: Tue,  7 Jun 2022 19:00:35 +0200	[thread overview]
Message-ID: <20220607170035.40090-1-cgzones@googlemail.com> (raw)
In-Reply-To: <20220517140748.24238-2-cgzones@googlemail.com>

The variable `curcon` is NULL in case the file has no current security
context.  Most C standard libraries handle it fine, avoid it nonetheless
for standard conformance.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
v2:
   print "<no context>" instead of "(null)"
---
 libselinux/src/selinux_restorecon.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c
index 9f5b326c..3c441119 100644
--- a/libselinux/src/selinux_restorecon.c
+++ b/libselinux/src/selinux_restorecon.c
@@ -744,7 +744,9 @@ static int restorecon_sb(const char *pathname, const struct stat *sb,
 			selinux_log(SELINUX_INFO,
 				    "%s %s from %s to %s\n",
 				    updated ? "Relabeled" : "Would relabel",
-				    pathname, curcon, newcon);
+				    pathname,
+				    curcon ? curcon : "<no context>",
+				    newcon);
 
 		if (flags->syslog_changes && !flags->nochange) {
 			if (curcon)
-- 
2.36.1


  parent reply	other threads:[~2022-06-07 17:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-17 14:07 [PATCH 1/2] libselinux: restorecon: add fallback for pre 3.6 Linux Christian Göttsche
2022-05-17 14:07 ` [PATCH 2/2] libselinux: restorecon: avoid printing NULL pointer Christian Göttsche
2022-05-18 13:54   ` James Carter
2022-05-20 12:46     ` Christian Göttsche
2022-06-07 17:00   ` Christian Göttsche [this message]
2022-06-28 21:05     ` [PATCH v2] " Nicolas Iooss
2022-06-29 19:09       ` James Carter
2022-06-30 19:35         ` Nicolas Iooss
2022-05-18 13:57 ` [PATCH 1/2] libselinux: restorecon: add fallback for pre 3.6 Linux 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=20220607170035.40090-1-cgzones@googlemail.com \
    --to=cgzones@googlemail.com \
    --cc=selinux@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.