Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
Check if file can be opened before using dup2
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Jun 30, 2018
1 parent 7660aa0 commit 7cd71ba
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Compiler/runtime/systemimpl.c
Expand Up @@ -593,6 +593,9 @@ int SystemImpl__systemCall(const char* str, const char* outFile)
if (*outFile) {
/* redirect stdout, stderr in the fork'ed process */
int fd = open(outFile, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if (fd < 0) {
_exit(1);
}
dup2(fd, 1);
dup2(fd, 2);
#if defined(__APPLE_CC__)
Expand Down

0 comments on commit 7cd71ba

Please sign in to comment.