Commit 6f4ef931ca92eb6846831801330d5e51a7893e34

Authored by Perry Werneck
1 parent 03104fba
Exists in master and in 1 other branch develop

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,11 +509,18 @@ main(int argc, char *argv[]) {
509 509
510 /* Open the output file. */ 510 /* Open the output file. */
511 if (argc == 3) { 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 if (o == NULL) { 519 if (o == NULL) {
514 perror(argv[2]); 520 perror(argv[2]);
515 exit(1); 521 exit(1);
516 } 522 }
  523 +
517 } else 524 } else
518 o = stdout; 525 o = stdout;
519 526