server: torrents: ensure path is allowed when mediainfo is requested

This commit is contained in:
Jesse Chan
2020-12-06 21:52:44 +08:00
parent f0b9ca4e2c
commit ebb4927b74
+3
View File
@@ -668,6 +668,9 @@ router.get('/:hash/mediainfo', async (req, res) => {
} }
const contentPath = fs.existsSync(path.join(directory, name)) ? path.join(directory, name) : directory; const contentPath = fs.existsSync(path.join(directory, name)) ? path.join(directory, name) : directory;
if (!isAllowedPath(contentPath)) {
callback(null, accessDeniedError());
}
try { try {
const mediainfoProcess = childProcess.execFile( const mediainfoProcess = childProcess.execFile(