mirror of https://github.com/halo-dev/halo
Fix vulnerability while deleting backup file
parent
d59877a9ce
commit
2056f528fd
|
@ -214,8 +214,13 @@ public class BackupServiceImpl implements BackupService {
|
|||
public void deleteHaloBackup(String fileName) {
|
||||
Assert.hasText(fileName, "File name must not be blank");
|
||||
|
||||
Path backupRootPath = Paths.get(haloProperties.getBackupDir());
|
||||
|
||||
// Get backup path
|
||||
Path backupPath = Paths.get(haloProperties.getBackupDir(), fileName);
|
||||
Path backupPath = backupRootPath.resolve(fileName);
|
||||
|
||||
// Check directory traversal
|
||||
run.halo.app.utils.FileUtils.checkDirectoryTraversal(backupRootPath, backupPath);
|
||||
|
||||
try {
|
||||
// Delete backup file
|
||||
|
|
Loading…
Reference in New Issue