From 76dfaad9a1dbace9bb9ef3f6c297a53143348385 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Fri, 27 Mar 2020 19:19:29 +0530 Subject: [PATCH] Set max DB size to 8 MiB --- src/db.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/db.rs b/src/db.rs index a3806a0..eba07e8 100644 --- a/src/db.rs +++ b/src/db.rs @@ -20,7 +20,10 @@ impl DB { let dirs = match File::open(&path) { Ok(file) => { let reader = BufReader::new(&file); - bincode::deserialize_from(reader).context("could not deserialize database")? + bincode::config() + .limit(8 * 1024 * 1024) // only databases upto 8 MiB are supported + .deserialize_from(reader) + .context("could not deserialize database")? } Err(err) => match err.kind() { io::ErrorKind::NotFound => Vec::::new(),