Fix snprintf truncated error
Link: https://github.com/SELinuxProject/selinux/pull/106
Signed-off-by: StidOfficial <[email protected]>
diff --git a/libsepol/src/kernel_to_cil.c b/libsepol/src/kernel_to_cil.c
index d173144..2c12ae9 100644
--- a/libsepol/src/kernel_to_cil.c
+++ b/libsepol/src/kernel_to_cil.c
@@ -536,7 +536,7 @@
struct strs *strs;
char *sid;
char *prev;
- char unknown[17];
+ char unknown[18];
unsigned i;
int rc;
@@ -550,7 +550,7 @@
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 @@
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 @@
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 7e04a13..219a248 100644
--- a/libsepol/src/kernel_to_conf.c
+++ b/libsepol/src/kernel_to_conf.c
@@ -434,7 +434,7 @@
struct ocontext *isid;
struct strs *strs;
char *sid;
- char unknown[17];
+ char unknown[18];
unsigned i;
int rc;
@@ -448,7 +448,7 @@
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 @@
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 @@
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 7fc29cb..4cb44e0 100644
--- a/libsepol/src/module_to_cil.c
+++ b/libsepol/src/module_to_cil.c
@@ -2562,7 +2562,7 @@
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 @@
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);