diff options
author | Richard Yao <[email protected]> | 2022-10-31 13:01:04 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2022-10-31 10:01:04 -0700 |
commit | dcce0dc5f009e8a3ec6dc48f5fc99abc4d74200f (patch) | |
tree | e2258989753a696b0d62aeebe814f1e4cdcb5d50 /lib/libshare | |
parent | b37d495e04ed6fc0012b2eccfff80af9e8887422 (diff) |
Fix oversights from 4170ae4e
4170ae4ea600fea6ac9daa8b145960c9de3915fc was intended to tackle TOCTOU
race conditions reported by CodeQL, but as an oversight, a file
descriptor was not closed and some comments were not updated.
Interestingly, CodeQL did not complain about the file descriptor leak,
so there is room for improvement in how we configure it to try to detect
this issue so that we get early warning about this.
In addition, an optimization opportunity was missed by mistake in
lib/libshare/os/linux/smb.c, which prevented us from truly closing the
TOCTOU race. This was also caught by Coverity.
Reported-by: Coverity (CID 1524424)
Reported-by: Coverity (CID 1526804)
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes #14109
Diffstat (limited to 'lib/libshare')
-rw-r--r-- | lib/libshare/os/linux/smb.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libshare/os/linux/smb.c b/lib/libshare/os/linux/smb.c index 8eb1894de..0679e8210 100644 --- a/lib/libshare/os/linux/smb.c +++ b/lib/libshare/os/linux/smb.c @@ -103,7 +103,7 @@ smb_retrieve_shares(void) goto out; } - if (stat(file_path, &eStat) == -1) { + if (fstat(fd, &eStat) == -1) { close(fd); rc = SA_SYSTEM_ERR; goto out; |