* [PATCH 1/2] libsepol: Check strdup() failures
@ 2019-06-17 12:02 Jokke Hämäläinen
0 siblings, 0 replies; only message in thread
From: Jokke Hämäläinen @ 2019-06-17 12:02 UTC (permalink / raw)
To: selinux
Check strdup() failures
Signed-off-by: Unto Sten <sten.unto@gmail.com>
---
libsepol/src/kernel_to_conf.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/libsepol/src/kernel_to_conf.c b/libsepol/src/kernel_to_conf.c
index 4f84ee8b..5fb4e838 100644
--- a/libsepol/src/kernel_to_conf.c
+++ b/libsepol/src/kernel_to_conf.c
@@ -450,6 +450,10 @@ static int write_sids_to_conf(FILE *out, const char *const *sid_to_str,
} else {
snprintf(unknown, 18, "%s%u", "UNKNOWN", i);
sid = strdup(unknown);
+ if (!sid) {
+ rc = -1;
+ goto exit;
+ }
}
rc = strs_add_at_index(strs, sid, i);
if (rc != 0) {
@@ -792,6 +796,10 @@ static int write_sensitivity_rules_to_conf(FILE *out, struct policydb *pdb)
j = level->level->sens - 1;
if (!sens_alias_map[j]) {
sens_alias_map[j] = strdup(name);
+ if (!sens_alias_map[j]) {
+ rc = -1;
+ goto exit;
+ }
} else {
alias = sens_alias_map[j];
sens_alias_map[j] = create_str("%s %s", 2, alias, name);
@@ -919,6 +927,10 @@ static int write_category_rules_to_conf(FILE *out, struct policydb *pdb)
j = cat->s.value - 1;
if (!cat_alias_map[j]) {
cat_alias_map[j] = strdup(name);
+ if (!cat_alias_map[j]) {
+ rc = -1;
+ goto exit;
+ }
} else {
alias = cat_alias_map[j];
cat_alias_map[j] = create_str("%s %s", 2, alias, name);
--
2.21.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-06-17 12:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-17 12:02 [PATCH 1/2] libsepol: Check strdup() failures Jokke Hämäläinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).