From 3d8ad35e9f0b067935e2527321dd507df31a07a6 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 31 Jul 2023 17:08:37 +0100 Subject: [PATCH] Don't sanitise selected paths from remote hosts. Closes #3006 * If the remote host disconnects during the selection process we will no longer have a valid connection, we shouldn't sanitise the resulting path according to local filenames. --- qrenderdoc/Windows/Dialogs/CaptureDialog.cpp | 10 ++++++---- qrenderdoc/Windows/Dialogs/CaptureDialog.h | 8 +++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/qrenderdoc/Windows/Dialogs/CaptureDialog.cpp b/qrenderdoc/Windows/Dialogs/CaptureDialog.cpp index c2569fa7d..fca0366f5 100644 --- a/qrenderdoc/Windows/Dialogs/CaptureDialog.cpp +++ b/qrenderdoc/Windows/Dialogs/CaptureDialog.cpp @@ -674,12 +674,14 @@ void CaptureDialog::on_exePathBrowse_clicked() } QString filename; + bool remoteSelection = false; if(m_Ctx.Replay().CurrentRemote().IsValid()) { VirtualFileDialog vfd(m_Ctx, initDir, this); RDDialog::show(&vfd); filename = vfd.chosenPath(); + remoteSelection = true; } else { @@ -688,7 +690,7 @@ void CaptureDialog::on_exePathBrowse_clicked() if(!filename.isEmpty()) { - SetExecutableFilename(filename); + SetExecutableFilename(filename, remoteSelection); if(m_Ctx.Replay().CurrentRemote().Protocol() && m_Ctx.Replay().CurrentRemote().Protocol()->GetProtocolName() == "adb") @@ -1031,11 +1033,11 @@ void CaptureDialog::fillProcessList() } } -void CaptureDialog::SetExecutableFilename(const rdcstr &filename) +void CaptureDialog::SetExecutableFilename(const rdcstr &filename, bool remoteSelection) { QString fn = filename; - if(!m_Ctx.Replay().CurrentRemote().IsValid()) + if(!m_Ctx.Replay().CurrentRemote().IsValid() && !remoteSelection) fn = QDir::toNativeSeparators(QFileInfo(fn).absoluteFilePath()); ui->exePath->setText(fn); @@ -1061,7 +1063,7 @@ void CaptureDialog::SetExecutableFilename(const rdcstr &filename) m_Ctx.Replay().CurrentRemote().SetLastCapturePath(fn); } - else + else if(!remoteSelection) { m_Ctx.Config().LastCapturePath = QFileInfo(fn).absolutePath(); m_Ctx.Config().LastCaptureExe = QFileInfo(fn).fileName(); diff --git a/qrenderdoc/Windows/Dialogs/CaptureDialog.h b/qrenderdoc/Windows/Dialogs/CaptureDialog.h index 955da5c0d..98adc16eb 100644 --- a/qrenderdoc/Windows/Dialogs/CaptureDialog.h +++ b/qrenderdoc/Windows/Dialogs/CaptureDialog.h @@ -60,7 +60,11 @@ public: bool IsInjectMode() override { return m_Inject; } void SetInjectMode(bool inject) override; - void SetExecutableFilename(const rdcstr &filename) override; + void SetExecutableFilename(const rdcstr &filename) override + { + SetExecutableFilename(filename, false); + } + void SetWorkingDirectory(const rdcstr &dir) override; void SetCommandLine(const rdcstr &cmd) override; void SetEnvironmentModifications(const rdcarray &modifications) override; @@ -106,6 +110,8 @@ private slots: void lineEdit_keyPress(QKeyEvent *); private: + void SetExecutableFilename(const rdcstr &filename, bool remoteSelection); + Ui::CaptureDialog *ui; ICaptureContext &m_Ctx; MainWindow *m_Main;