Skip to content

Commit

Permalink
Remove usage of function chmod(2) to use fchmod(2)
Browse files Browse the repository at this point in the history
Race condition possibility; CWE-362: Concurrent Execution using Shared
Resource with Improper Synchronization ('Race Condition')

Thanks to PA193 project
https://github.com/vegaMato/PCSC-lite-project-tasks
  • Loading branch information
WW0nka authored and LudovicRousseau committed Jan 14, 2019
1 parent 4300438 commit 36c8eae
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pcscdaemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,12 +685,13 @@ int main(int argc, char **argv)
"writing " PCSCLITE_RUN_PID " failed: %s",
strerror(errno));
}
(void)close(f);

/* set mode so that the file is world readable even is umask is
* restrictive
* The file is used by libpcsclite */
(void)chmod(PCSCLITE_RUN_PID, mode);
(void)fchmod(f, mode);

(void)close(f);
}
else
Log2(PCSC_LOG_CRITICAL, "cannot create " PCSCLITE_RUN_PID ": %s",
Expand Down

0 comments on commit 36c8eae

Please sign in to comment.