All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] libsepol: Replace constant with sizeof()
@ 2019-06-17 12:02 Jokke Hämäläinen
  2019-06-17 17:53 ` William Roberts
  0 siblings, 1 reply; 3+ messages in thread
From: Jokke Hämäläinen @ 2019-06-17 12:02 UTC (permalink / raw)
  To: selinux


Replace constant 18 with safer use of sizeof()

Signed-off-by: Unto Sten <sten.unto@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] libsepol: Replace constant with sizeof()
  2019-06-17 12:02 [PATCH 2/2] libsepol: Replace constant with sizeof() Jokke Hämäläinen
@ 2019-06-17 17:53 ` William Roberts
  2019-06-19 16:04   ` William Roberts
  0 siblings, 1 reply; 3+ messages in thread
From: William Roberts @ 2019-06-17 17:53 UTC (permalink / raw)
  To: Jokke Hämäläinen; +Cc: selinux

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@kolttonen.fi> wrote:
>
>
> Replace constant 18 with safer use of sizeof()
>
> Signed-off-by: Unto Sten <sten.unto@gmail.com>
> ---
>  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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] libsepol: Replace constant with sizeof()
  2019-06-17 17:53 ` William Roberts
@ 2019-06-19 16:04   ` William Roberts
  0 siblings, 0 replies; 3+ messages in thread
From: William Roberts @ 2019-06-19 16:04 UTC (permalink / raw)
  To: Jokke Hämäläinen; +Cc: selinux

merged

On Mon, Jun 17, 2019 at 10:53 AM William Roberts
<bill.c.roberts@gmail.com> 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@kolttonen.fi> wrote:
> >
> >
> > Replace constant 18 with safer use of sizeof()
> >
> > Signed-off-by: Unto Sten <sten.unto@gmail.com>
> > ---
> >  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
> >

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-19 16:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-17 12:02 [PATCH 2/2] libsepol: Replace constant with sizeof() Jokke Hämäläinen
2019-06-17 17:53 ` William Roberts
2019-06-19 16:04   ` William Roberts

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.