π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Bound Paste input reads
Manav Rathi1b5eaf018bea
diff --git a/rust/apps/cli-next/src/api.rs b/rust/apps/cli-next/src/api.rsindex c99840c05e..78a4fbf18b 100644--- a/rust/apps/cli-next/src/api.rs+++ b/rust/apps/cli-next/src/api.rs@@ -119,8 +119,8 @@ pub async fn run(app: App, args: ApiArgs, selected: Option<&str>, options: &Opti}let mut headers = HeaderMap::new();if let Some(path) = args.headers {- let values: BTreeMap<String, String> =- parse_json(&read_input(&path)?).context("headers must be a JSON object of strings")?;+ let values: BTreeMap<String, String> = parse_json(&read_input(&path, u64::MAX)?)+ .context("headers must be a JSON object of strings")?;for (name, value) in values {let mut value = HeaderValue::from_str(&Zeroizing::new(value))?;value.set_sensitive(true);@@ -148,7 +148,7 @@ pub async fn run(app: App, args: ApiArgs, selected: Option<&str>, options: &Optilet method = Method::from_bytes(args.method.to_ascii_uppercase().as_bytes())?;let mut request = http()?.request(method, url).headers(headers);if let Some(path) = args.body {- request = request.body(read_input(&path)?.to_vec());+ request = request.body(read_input(&path, u64::MAX)?.to_vec());}let mut response = request.send().await.map_err(ente_core::http::Error::from)?;let status = response.status();diff --git a/rust/apps/cli-next/src/login.rs b/rust/apps/cli-next/src/login.rsindex 4ebb78247d..66603fd6a0 100644--- a/rust/apps/cli-next/src/login.rs+++ b/rust/apps/cli-next/src/login.rs@@ -167,7 +167,7 @@ struct Credentials {impl Credentials {fn read(path: &Path) -> Result<Self> {- parse_json(&read_input(path)?)+ parse_json(&read_input(path, u64::MAX)?).context("login input must contain email and password, with optional otp and totp")}diff --git a/rust/apps/cli-next/src/main.rs b/rust/apps/cli-next/src/main.rsindex 3cb1459124..16f5565f4f 100644--- a/rust/apps/cli-next/src/main.rs+++ b/rust/apps/cli-next/src/main.rs@@ -277,15 +277,17 @@ fn output_account(state: State, index: usize, json_output: bool) -> Result<()> {}}-fn read_input(path: &Path) -> Result<Zeroizing<Vec<u8>>> {+fn read_input(path: &Path, limit: u64) -> Result<Zeroizing<Vec<u8>>> {let mut bytes = Zeroizing::new(Vec::new());if path == Path::new("-") {std::io::stdin()+ .take(limit).read_to_end(&mut bytes).context("cannot read stdin")?;} else {std::fs::File::open(path).with_context(|| format!("cannot open {}", path.display()))?+ .take(limit).read_to_end(&mut bytes).with_context(|| format!("cannot read {}", path.display()))?;}diff --git a/rust/apps/cli-next/src/paste.rs b/rust/apps/cli-next/src/paste.rsindex e5a9a1b40c..e93179805f 100644--- a/rust/apps/cli-next/src/paste.rs+++ b/rust/apps/cli-next/src/paste.rs@@ -32,10 +32,13 @@ pub async fn run(command: PasteCommand, options: &Options) -> Result<()> {input.is_some() || !std::io::stdin().is_terminal(),"provide TEXT, --input PATH|-, or piped stdin");- String::from_utf8(- read_input(input.as_deref().unwrap_or(Path::new("-")))?.to_vec(),- )- .context("paste input must be UTF-8")?+ let max_bytes = ente_paste::MAX_PASTE_CHARS * 4;+ let bytes = read_input(+ input.as_deref().unwrap_or(Path::new("-")),+ (max_bytes + 1) as u64,+ )?;+ ensure!(bytes.len() <= max_bytes, ente_paste::Error::TextTooLong);+ String::from_utf8(bytes.to_vec()).context("paste input must be UTF-8")?}});ente_paste::validate_text(&text)?;