File: 1001_ureq.patch

package info (click to toggle)
rust-binary-install 0.4.1%2Bds-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 280 kB
  • sloc: makefile: 2; sh: 1
file content (53 lines) | stat: -rw-r--r-- 1,573 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Description: use newer major version of crate ureq, and use feature "platform-verifier"
Author: Jonas Smedegaard <dr@jones.dk>
Last-Update: 2026-01-20
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,7 +11,7 @@
 
 [dependencies]
 anyhow = "1.0"
-ureq = "2.6"
+ureq = { version = "3", features = ["platform-verifier"] }
 dirs-next = "2.0.0"
 flate2 = "1.0"
 fs4 = "0.13.1"
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -10,6 +10,7 @@
 use std::hash::{Hash, Hasher};
 use std::io;
 use std::path::{Path, PathBuf};
+use ureq::get;
 
 /// Global cache for wasm-pack, currently containing binaries downloaded from
 /// urls like wasm-bindgen and such.
@@ -389,18 +390,17 @@
 }
 
 fn download_binary(url: &str) -> Result<Vec<u8>> {
-    let response = ureq::get(url).call()?;
+    let response = get(url).call()?;
 
     let status_code = response.status();
 
-    if (200..300).contains(&status_code) {
-        // note malicious server might exhaust our memory
-        let len: usize = response
-            .header("Content-Length")
-            .and_then(|s| s.parse().ok())
-            .unwrap_or(0);
-        let mut bytes: Vec<u8> = Vec::with_capacity(len);
-        response.into_reader().read_to_end(&mut bytes)?;
+    if status_code.is_success() {
+        // Read response body with 100 MB limit
+        let bytes = response
+            .into_body()
+            .into_with_config()
+            .limit(100 * 1024 * 1024) // 100 MB
+            .read_to_vec()?;
         Ok(bytes)
     } else {
         bail!(