Skip to content

Commit

Permalink
Close open files on exec
Browse files Browse the repository at this point in the history
Not really relevant for single-threaded selint, but pleases clang-tidy.
  • Loading branch information
cgzones committed Jan 8, 2024
1 parent ea4018f commit 894af1c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/parse_fc.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ bool check_for_fc_macro(const char *line, const struct string_list *custom_fc_ma

struct policy_node *parse_fc_file(const char *filename, const struct string_list *custom_fc_macros)
{
FILE *fd = fopen(filename, "r");
FILE *fd = fopen(filename, "re");

if (!fd) {
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct policy_node *parse_one_file(const char *filename, enum node_flavor flavor
set_current_module_name(mod_name);
free(copy);

FILE *f = fopen(filename, "r");
FILE *f = fopen(filename, "re");
if (!f) {
printf("%sError%s: Failed to open %s: %s\n", color_error(), color_reset(), filename, strerror(errno));
return NULL;
Expand Down
8 changes: 4 additions & 4 deletions src/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ enum selint_error load_access_vectors_source(const char *av_path)

set_current_module_name(av_path);

FILE *f = fopen(av_path, "r");
FILE *f = fopen(av_path, "re");
if (!f) {
printf("%sError%s: Failed to open %s: %s\n", color_error(), color_reset(), av_path, strerror(errno));
return SELINT_IO_ERROR;
Expand Down Expand Up @@ -193,7 +193,7 @@ static char *strip_space(char *str)

enum selint_error load_modules_source(const char *modules_conf_path)
{
FILE *fd = fopen(modules_conf_path, "r");
FILE *fd = fopen(modules_conf_path, "re");

if (!fd) {
return SELINT_IO_ERROR;
Expand Down Expand Up @@ -242,7 +242,7 @@ enum selint_error load_modules_source(const char *modules_conf_path)

enum selint_error load_obj_perm_sets_source(const char *obj_perm_sets_path)
{
FILE *f = fopen(obj_perm_sets_path, "r");
FILE *f = fopen(obj_perm_sets_path, "re");
if (!f) {
return SELINT_IO_ERROR;
}
Expand Down Expand Up @@ -321,7 +321,7 @@ static enum selint_error load_global_conditions_file(const char *path)

set_current_module_name("__global__");

FILE *f = fopen(path, "r");
FILE *f = fopen(path, "re");
if (!f) {
printf("%sError%s: Failed to open file %s: %s\n", color_error(), color_reset(), path, strerror(errno));
return SELINT_IO_ERROR;
Expand Down

0 comments on commit 894af1c

Please sign in to comment.