All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Iooss <nicolas.iooss@m4x.org>
To: selinux@vger.kernel.org
Subject: [PATCH 1/1] Fix snprintf truncated error
Date: Thu, 25 Oct 2018 21:45:48 +0200	[thread overview]
Message-ID: <20181025194548.21505-1-nicolas.iooss@m4x.org> (raw)

From: Mr Stid <stidofficiel@gmail.com>

Link: https://github.com/SELinuxProject/selinux/pull/106
Signed-off-by: StidOfficial <stidofficiel@gmail.com>
---
 libsepol/src/kernel_to_cil.c  | 8 ++++----
 libsepol/src/kernel_to_conf.c | 8 ++++----
 libsepol/src/module_to_cil.c  | 4 ++--
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/libsepol/src/kernel_to_cil.c b/libsepol/src/kernel_to_cil.c
index d173144ef618..2c12ae9bf7f1 100644
--- a/libsepol/src/kernel_to_cil.c
+++ b/libsepol/src/kernel_to_cil.c
@@ -536,7 +536,7 @@ static int write_sids_to_cil(FILE *out, const char *const *sid_to_str,
 	struct strs *strs;
 	char *sid;
 	char *prev;
-	char unknown[17];
+	char unknown[18];
 	unsigned i;
 	int rc;
 
@@ -550,7 +550,7 @@ static int write_sids_to_cil(FILE *out, const char *const *sid_to_str,
 		if (i < num_sids) {
 			sid = (char *)sid_to_str[i];
 		} else {
-			snprintf(unknown, 17, "%s%u", "UNKNOWN", i);
+			snprintf(unknown, 18, "%s%u", "UNKNOWN", i);
 			sid = strdup(unknown);
 		}
 		rc = strs_add_at_index(strs, sid, i);
@@ -2498,7 +2498,7 @@ static int write_sid_context_rules_to_cil(FILE *out, struct policydb *pdb, const
 	struct ocontext *isid;
 	struct strs *strs;
 	char *sid;
-	char unknown[17];
+	char unknown[18];
 	char *ctx, *rule;
 	unsigned i;
 	int rc = -1;
@@ -2513,7 +2513,7 @@ static int write_sid_context_rules_to_cil(FILE *out, struct policydb *pdb, const
 		if (i < num_sids) {
 			sid = (char *)sid_to_str[i];
 		} else {
-			snprintf(unknown, 17, "%s%u", "UNKNOWN", i);
+			snprintf(unknown, 18, "%s%u", "UNKNOWN", i);
 			sid = unknown;
 		}
 
diff --git a/libsepol/src/kernel_to_conf.c b/libsepol/src/kernel_to_conf.c
index 7e04a13bd1ff..219a2489feba 100644
--- a/libsepol/src/kernel_to_conf.c
+++ b/libsepol/src/kernel_to_conf.c
@@ -434,7 +434,7 @@ static int write_sids_to_conf(FILE *out, const char *const *sid_to_str,
 	struct ocontext *isid;
 	struct strs *strs;
 	char *sid;
-	char unknown[17];
+	char unknown[18];
 	unsigned i;
 	int rc;
 
@@ -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, 17, "%s%u", "UNKNOWN", i);
+			snprintf(unknown, 18, "%s%u", "UNKNOWN", i);
 			sid = strdup(unknown);
 		}
 		rc = strs_add_at_index(strs, sid, i);
@@ -2358,7 +2358,7 @@ static int write_sid_context_rules_to_conf(FILE *out, struct policydb *pdb, cons
 	struct ocontext *isid;
 	struct strs *strs;
 	char *sid;
-	char unknown[17];
+	char unknown[18];
 	char *ctx, *rule;
 	unsigned i;
 	int rc;
@@ -2373,7 +2373,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, 17, "%s%u", "UNKNOWN", i);
+			snprintf(unknown, 18, "%s%u", "UNKNOWN", i);
 			sid = unknown;
 		}
 
diff --git a/libsepol/src/module_to_cil.c b/libsepol/src/module_to_cil.c
index 7fc29cbda2de..4cb44e0ee657 100644
--- a/libsepol/src/module_to_cil.c
+++ b/libsepol/src/module_to_cil.c
@@ -2562,7 +2562,7 @@ static int ocontext_isid_to_cil(struct policydb *pdb, const char *const *sid_to_
 	struct sid_item *head = NULL;
 	struct sid_item *item = NULL;
 	char *sid;
-	char unknown[17];
+	char unknown[18];
 	unsigned i;
 
 	for (isid = isids; isid != NULL; isid = isid->next) {
@@ -2570,7 +2570,7 @@ static int ocontext_isid_to_cil(struct policydb *pdb, const char *const *sid_to_
 		if (i < num_sids) {
 			sid = (char*)sid_to_string[i];
 		} else {
-			snprintf(unknown, 17, "%s%u", "UNKNOWN", i);
+			snprintf(unknown, 18, "%s%u", "UNKNOWN", i);
 			sid = unknown;
 		}
 		cil_println(0, "(sid %s)", sid);
-- 
2.19.0


             reply	other threads:[~2018-10-25 19:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-25 19:45 Nicolas Iooss [this message]
2018-10-27  7:56 ` [PATCH 1/1] Fix snprintf truncated error Nicolas Iooss

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=20181025194548.21505-1-nicolas.iooss@m4x.org \
    --to=nicolas.iooss@m4x.org \
    --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.