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 authored and Claudia Pellegrino committed Nov 9, 2023
1 parent f3fc7f3 commit d7a150e
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 @@ -5830,7 +5830,7 @@ int check_group_uucp()
strcat(testLockAbsFileName, testLockFileDirName);
strcat(testLockAbsFileName, "/");
strcat(testLockAbsFileName, testLockFileName);
if ( 0 == mkstemp(testLockAbsFileName) )
if ( 0 == strlen(mktemp(testLockAbsFileName)) )
{
free(testLockAbsFileName);
report_error("check_group_uucp(): mktemp malformed string - \
Expand Down

0 comments on commit d7a150e

Please sign in to comment.