Skip to content

Commit

Permalink
sys/fs: fix fs_fopen read only mode (should not create file) (#719)
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers authored Feb 28, 2023
1 parent c9ff512 commit 0b1ebd2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/sys/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ int fs_fopen(FILE **fp, const char *file, const char *mode)
FILE *pfile;
int fd;

if (!fp || !file || !mode)
if (!fp || !file || !str_isset(mode))
return EINVAL;

if (fs_isfile(file))
if (mode[0] == 'r' || fs_isfile(file))
goto fopen;

fd = open(file, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR);
Expand Down

0 comments on commit 0b1ebd2

Please sign in to comment.