Skip to content

Commit

Permalink
fix(security): fix file system race condition (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
oyo authored Mar 21, 2024
1 parent 8e4307d commit 5a8fa80
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/documentation/Release.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ import dirTree from 'directory-tree'

class MDHelper {
readContent(path) {
if (!fs.lstatSync(path).isFile()) return ''
try {
const fd = fs.openSync(path, 'r')
if (!fs.lstatSync(fd).isFile()) {
return ''
}
return fs.existsSync(fd) ? fs.readFileSync(fd, 'utf8') : ''
} catch (err) {
return ''
Expand Down

0 comments on commit 5a8fa80

Please sign in to comment.