Re: [PATCH 2/2] libsepol: Replace constant with sizeof()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



merged

On Mon, Jun 17, 2019 at 10:53 AM William Roberts
<bill.c.roberts@xxxxxxxxx> wrote:
>
> ack on the series, staged: https://github.com/SELinuxProject/selinux/pull/163
>
> On Mon, Jun 17, 2019 at 5:02 AM Jokke Hämäläinen
> <jokke.hamalainen@xxxxxxxxxxxx> wrote:
> >
> >
> > Replace constant 18 with safer use of sizeof()
> >
> > Signed-off-by: Unto Sten <sten.unto@xxxxxxxxx>
> > ---
> >  libsepol/src/kernel_to_conf.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/libsepol/src/kernel_to_conf.c b/libsepol/src/kernel_to_conf.c
> > index 5fb4e838..930bafab 100644
> > --- a/libsepol/src/kernel_to_conf.c
> > +++ b/libsepol/src/kernel_to_conf.c
> > @@ -448,7 +448,7 @@ static int write_sids_to_conf(FILE *out, const char *const *sid_to_str,
> >                 if (i < num_sids) {
> >                         sid = (char *)sid_to_str[i];
> >                 } else {
> > -                       snprintf(unknown, 18, "%s%u", "UNKNOWN", i);
> > +                       snprintf(unknown, sizeof(unknown), "%s%u", "UNKNOWN", i);
> >                         sid = strdup(unknown);
> >                         if (!sid) {
> >                                 rc = -1;
> > @@ -2376,7 +2376,7 @@ static int write_sid_context_rules_to_conf(FILE *out, struct policydb *pdb, cons
> >                 if (i < num_sids) {
> >                         sid = (char *)sid_to_str[i];
> >                 } else {
> > -                       snprintf(unknown, 18, "%s%u", "UNKNOWN", i);
> > +                       snprintf(unknown, sizeof(unknown), "%s%u", "UNKNOWN", i);
> >                         sid = unknown;
> >                 }
> >
> > --
> > 2.21.0
> >




[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux