diff options
| author | David Lönnhager <david.l@mullvad.net> | 2025-06-16 17:53:45 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2025-06-16 18:14:10 +0200 |
| commit | c958c1fac98ea3537d1d14fa5ce9ca4f66ebaebc (patch) | |
| tree | 4908d348448edc864c2c020e2506e71fce70cd82 | |
| parent | b176627133940597c854d349eed8112f67795543 (diff) | |
| download | mullvadvpn-c958c1fac98ea3537d1d14fa5ce9ca4f66ebaebc.tar.xz mullvadvpn-c958c1fac98ea3537d1d14fa5ce9ca4f66ebaebc.zip | |
Skip incomplete installers for loader in offline mode
Co-authored-by: Markus Pettersson <markus.pettersson@mullvad.net>
| -rw-r--r-- | installer-downloader/src/controller.rs | 2 | ||||
| -rw-r--r-- | mullvad-update/src/client/app.rs | 23 |
2 files changed, 7 insertions, 18 deletions
diff --git a/installer-downloader/src/controller.rs b/installer-downloader/src/controller.rs index 21f92d9a7f..94a1a84e73 100644 --- a/installer-downloader/src/controller.rs +++ b/installer-downloader/src/controller.rs @@ -325,6 +325,7 @@ where queue.queue_main(|self_| { self_.quit(); }); + std::future::pending::<()>().await; } Action::InstallExistingVersion { cached_app_installer: installer, @@ -375,6 +376,7 @@ where queue.queue_main(|self_| { self_.quit(); }); + std::future::pending::<()>().await; } Some(Action::InstallExistingVersion { .. }) => unreachable!(), } diff --git a/mullvad-update/src/client/app.rs b/mullvad-update/src/client/app.rs index 10c3aac2df..79a1018917 100644 --- a/mullvad-update/src/client/app.rs +++ b/mullvad-update/src/client/app.rs @@ -206,35 +206,22 @@ pub fn bin_path(app_version: &mullvad_version::Version, cache_dir: &Path) -> Pat impl InstallerFile<false> { /// Create an unverified [InstallerFile] from a cache_dir and some metadata. - pub fn try_from_version( - cache_dir: &Path, - version: crate::version::Version, - ) -> anyhow::Result<Self> { - let path = bin_path(&version.version, cache_dir); - if !path.exists() { - bail!("Installer file does not exist at path: {}", path.display()); - } - Ok(Self { - path, - app_version: version.version, - app_size: version.size, - app_sha256: version.sha256, - }) - } - pub fn try_from_installer( cache_dir: &Path, app_version: mullvad_version::Version, installer: crate::format::Installer, ) -> anyhow::Result<Self> { let path = bin_path(&app_version, cache_dir); - if !path.exists() { - bail!("Installer file does not exist at path: {}", path.display()); + // Sanity check (without verifying) installer to avoid returning partial downloads + let metadata = path.metadata().context("Failed to get file metadata")?; + if usize::try_from(metadata.len()).context("Invalid file size")? != installer.size { + bail!("Unexpected file size"); } let app_sha256 = hex::decode(installer.sha256) .context("Invalid checksum hex")? .try_into() .map_err(|_| anyhow::anyhow!("Invalid checksum length"))?; + Ok(Self { path, app_version, |
