Skip to content

Commit

Permalink
Fix FD leak when checking lock dir permissions.
Browse files Browse the repository at this point in the history
`mkstemp(3)` creates and opens a file descriptor for a temporary file,
but this file descriptor was immediately discarded in favour of
`fopen(3)`'ing the file by name and using that `FILE *` stream. I'm sure
whoever originally wrote this code meant to use `mktemp(3)` instead,
which only creates a unique file from a template name (equivalent to
`mktemp(1)`).
  • Loading branch information
MrDOS committed May 3, 2021
1 parent 6c54eeb commit 60bdce0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/c/src/SerialImp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5835,7 +5835,7 @@ int check_group_uucp()
strcat(testLockAbsFileName, testLockFileDirName);
strcat(testLockAbsFileName, "/");
strcat(testLockAbsFileName, testLockFileName);
if ( 0 == mkstemp(testLockAbsFileName) )
if ( NULL == mktemp(testLockAbsFileName) )
{
free(testLockAbsFileName);
report_error("check_group_uucp(): mktemp malformed string - \
Expand Down

0 comments on commit 60bdce0

Please sign in to comment.