mirror of
https://github.com/SELinuxProject/selinux
synced 2025-02-22 20:46:52 +00:00
libsepol: Check strdup() failures
Check strdup() failures Signed-off-by: Unto Sten <sten.unto@gmail.com>
This commit is contained in:
parent
dbffdf7135
commit
e8d880e0a2
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user