From 912b88e6062de61c50cdbc6754b5e59d157a5882 Mon Sep 17 00:00:00 2001 From: holly sparkles Date: Mon, 15 Jan 2024 13:01:26 +0100 Subject: [PATCH] Fix for buffer overflow in fetch_latest_one Signed-off-by: Jordan Doyle --- src/database/schema/commit.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/database/schema/commit.rs b/src/database/schema/commit.rs index 7454113..4c60a2e 100644 --- a/src/database/schema/commit.rs +++ a/src/database/schema/commit.rs @@ -189,7 +189,7 @@ pub fn fetch_latest_one(&self) -> Result, anyhow::Error> { let mut key = self.prefix.to_vec(); - key.extend_from_slice(&(self.len()? - 1).to_be_bytes()); + key.extend_from_slice(&(self.len()?.saturating_sub(1)).to_be_bytes()); let cf = self .db -- rgit 0.1.3