diff --git a/Cargo.toml b/Cargo.toml index 37197fa..b88ecd1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,8 @@ edition = "2018" async = ["tokio"] [profile.release] -opt-level = 3 +opt-level = 1 # opt-level >1 causes strange bug in regards to size of memory map??? it still happens on one just not as much???? +# To test map a large file in /tmp a bunch of times and hash it. lto = "fat" codegen-units = 1 @@ -21,4 +22,4 @@ tokio = {version = "0.2", features= ["full"], optional=true} reqwest = {version = "0.10", features= ["stream"]} memmap = "0.7" getrandom = "0.1" -base64 = "0.12" \ No newline at end of file +base64 = "0.12" diff --git a/TODO b/TODO index ea83225..3c90a32 100644 --- a/TODO +++ b/TODO @@ -4,3 +4,6 @@ Remove Cargo.lock when termprogress is uploaded and Cargo.toml is properly forma New UI: lolistealer --number 5 output-dir/ + + +!!! memmap slice size is incorrect on release build diff --git a/src/loli/encoding.rs b/src/loli/encoding.rs index 4708b48..65a82df 100644 --- a/src/loli/encoding.rs +++ b/src/loli/encoding.rs @@ -91,7 +91,7 @@ fn find_back(haystack: &[u8], needle: &[u8]) -> Option { } const MARKER_BASE64_BEGIN: &[u8] = b"base64,"; -const MARKER_BASE64_END: &[u8] = b"' />"; //Search from end here with .rev() +const MARKER_BASE64_END: &[u8] = b"' />) -> Result, error::DecodeError> @@ -102,11 +102,15 @@ pub(super) fn find_bounds(from: impl AsRef<[u8]>) -> Result, error: let start = start + MARKER_BASE64_BEGIN.len(); if let Some(end) = find_back(&from[start..], MARKER_BASE64_END) {//find_back(from, MARKER_BASE64_END) { let end = end - MARKER_BASE64_END.len(); - return Ok(Range { + Ok(Range { start, end: end + start, - }); + }) + } else { + //println!("WAAAAAAH: {:?}", std::str::from_utf8(&from[start..])); + Err(error::DecodeError::Bounds(error::Bound::End)) } + } else { + Err(error::DecodeError::Bounds(error::Bound::Start)) } - Err(error::DecodeError::Bounds) } diff --git a/src/loli/error.rs b/src/loli/error.rs index 25a2482..6b55181 100644 --- a/src/loli/error.rs +++ b/src/loli/error.rs @@ -5,6 +5,14 @@ use std::{ path::PathBuf, }; +/// Start or end bounds +#[derive(Debug)] +pub enum Bound +{ + Start, + End, +} + #[derive(Debug)] pub enum DecodeError { @@ -15,7 +23,7 @@ pub enum DecodeError /// Map contained invalid base64 Base64, /// Couldn't find base64 bounds - Bounds, + Bounds(Bound), /// Bad size Size, } @@ -38,7 +46,8 @@ impl fmt::Display for DecodeError Self::Map(io, path) => write!(f, "mmap (file {:?}) failed: {}", path, io), Self::Corrupt => write!(f, "data was corrupt (invalid utf-8)"), Self::Base64 => write!(f, "data was corrupt (invalid base64)"), - Self::Bounds => write!(f, "couldn't find base64 bounds"), + Self::Bounds(Bound::Start) => write!(f, "couldn't find base64 bounds (start)"), + Self::Bounds(Bound::End) => write!(f, "couldn't find base64 bounds (end)"), Self::Size => write!(f, "bad size"), } }