Message ID | 20220607170035.40090-1-cgzones@googlemail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 956bda08f618 |
Headers | show |
Series | [v2] libselinux: restorecon: avoid printing NULL pointer | expand |
On Tue, Jun 7, 2022 at 7:00 PM Christian Göttsche <cgzones@googlemail.com> wrote: > > 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> Hello, What is the status of this patch? As it looks good to me, I can merge it if nobody has any more comments. Acked-by: Nicolas Iooss <nicolas.iooss@m4x.org> Thanks, Nicolas > --- > 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 >
On Tue, Jun 28, 2022 at 5:06 PM Nicolas Iooss <nicolas.iooss@m4x.org> wrote: > > On Tue, Jun 7, 2022 at 7:00 PM Christian Göttsche > <cgzones@googlemail.com> wrote: > > > > 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> > > Hello, > What is the status of this patch? As it looks good to me, I can merge > it if nobody has any more comments. > This patch is fine. Patch 1 fixes a commit that has been reverted, so it is not needed. Thanks, Jim > Acked-by: Nicolas Iooss <nicolas.iooss@m4x.org> > > Thanks, > Nicolas > > > --- > > 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 > > >
On Wed, Jun 29, 2022 at 9:09 PM James Carter <jwcart2@gmail.com> wrote: > > On Tue, Jun 28, 2022 at 5:06 PM Nicolas Iooss <nicolas.iooss@m4x.org> wrote: > > > > On Tue, Jun 7, 2022 at 7:00 PM Christian Göttsche > > <cgzones@googlemail.com> wrote: > > > > > > 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> > > > > Hello, > > What is the status of this patch? As it looks good to me, I can merge > > it if nobody has any more comments. > > > > This patch is fine. Patch 1 fixes a commit that has been reverted, so > it is not needed. > Thanks, > Jim This patch is now applied. Thanks, Nicolas > > Acked-by: Nicolas Iooss <nicolas.iooss@m4x.org> > > > > Thanks, > > Nicolas > > > > > --- > > > 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 > > > > >
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)
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(-)