Commit 6f4ef931ca92eb6846831801330d5e51a7893e34
1 parent
03104fba
Exists in
master
and in
1 other branch
Fixing CodeQL warning.
Showing
1 changed file
with
8 additions
and
1 deletions
Show diff stats
src/mkfb/mkfb.c
... | ... | @@ -509,11 +509,18 @@ main(int argc, char *argv[]) { |
509 | 509 | |
510 | 510 | /* Open the output file. */ |
511 | 511 | if (argc == 3) { |
512 | - o = fopen(argv[2], "w"); | |
512 | + int fd = creat(argv[2], S_IWUSR | S_IRUSR); | |
513 | + if(fd < 0) { | |
514 | + perror(argv[2]); | |
515 | + exit(1); | |
516 | + } | |
517 | + | |
518 | + o = fdopen(fd,"w"); | |
513 | 519 | if (o == NULL) { |
514 | 520 | perror(argv[2]); |
515 | 521 | exit(1); |
516 | 522 | } |
523 | + | |
517 | 524 | } else |
518 | 525 | o = stdout; |
519 | 526 | ... | ... |