Skip to content

Commit

Permalink
Make attachment related file writings use _masked function
Browse files Browse the repository at this point in the history
Signed-off-by: Doron Behar <doron.behar@gmail.com>
  • Loading branch information
doronbehar authored and flatcap committed Apr 29, 2024
1 parent 81f5250 commit f46ba57
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions attach/mutt_attach.c
Original file line number Diff line number Diff line change
Expand Up @@ -885,11 +885,11 @@ int mutt_pipe_attachment(FILE *fp, struct Body *b, const char *path, const char
static FILE *save_attachment_open(const char *path, enum SaveAttach opt)
{
if (opt == MUTT_SAVE_APPEND)
return mutt_file_fopen(path, "a");
return mutt_file_fopen_masked(path, "a");
if (opt == MUTT_SAVE_OVERWRITE)
return mutt_file_fopen(path, "w");
return mutt_file_fopen_masked(path, "w");

return mutt_file_fopen(path, "w");
return mutt_file_fopen_masked(path, "w");
}

/**
Expand Down Expand Up @@ -1048,11 +1048,11 @@ int mutt_decode_save_attachment(FILE *fp, struct Body *b, const char *path,
state.flags = flags;

if (opt == MUTT_SAVE_APPEND)
state.fp_out = mutt_file_fopen(path, "a");
state.fp_out = mutt_file_fopen_masked(path, "a");
else if (opt == MUTT_SAVE_OVERWRITE)
state.fp_out = mutt_file_fopen(path, "w");
state.fp_out = mutt_file_fopen_masked(path, "w");
else
state.fp_out = mutt_file_fopen(path, "w");
state.fp_out = mutt_file_fopen_masked(path, "w");

if (!state.fp_out)
{
Expand Down
2 changes: 1 addition & 1 deletion send/sendlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ struct Body *mutt_make_message_attach(struct Mailbox *m, struct Email *e,

struct Buffer *buf = buf_pool_get();
buf_mktemp(buf);
fp = mutt_file_fopen(buf_string(buf), "w+");
fp = mutt_file_fopen_masked(buf_string(buf), "w+");

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This argument to a file access function is derived from
user input (string read by fread)
and then passed to mutt_file_fopen_masked_full(path), which calls mutt_file_fopen_full(path), which calls fopen(__filename).
This argument to a file access function is derived from
user input (string read by fread)
and then passed to mutt_file_fopen_masked_full(path), which calls mutt_file_fopen_full(path), which calls mutt_file_open(path), which calls open(__path).
if (!fp)
{
buf_pool_release(&buf);
Expand Down

0 comments on commit f46ba57

Please sign in to comment.