Skip to content

Commit

Permalink
libsepol: Replace constant with sizeof()
Browse files Browse the repository at this point in the history
Replace constant 18 with safer use of sizeof()

Signed-off-by: Unto Sten <sten.unto@gmail.com>
  • Loading branch information
Jokke Hämäläinen authored and William Roberts committed Jun 19, 2019
1 parent e8d880e commit eb2a875
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libsepol/src/kernel_to_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit eb2a875

Please sign in to comment.