Use memmem for finding needle in haystack

This commit is contained in:
topjohnwu
2024-04-10 14:57:44 -07:00
parent ffc1e38e48
commit c50ee722a1
2 changed files with 33 additions and 4 deletions

View File

@ -21,8 +21,8 @@ use base::libc::{
S_IWOTH, S_IWUSR, S_IXGRP, S_IXOTH, S_IXUSR,
};
use base::{
log_err, map_args, EarlyExitExt, FsPath, LoggedResult, MappedFile, ResultExt, Utf8CStr,
WriteExt,
log_err, map_args, BytesExt, EarlyExitExt, FsPath, LoggedResult, MappedFile, ResultExt,
Utf8CStr, WriteExt,
};
use crate::ffi::{unxz, xz};
@ -246,7 +246,7 @@ impl Cpio {
continue;
}
if name == "TRAILER!!!" {
match data[pos..].windows(6).position(|x| x == b"070701") {
match data[pos..].find(b"070701") {
Some(x) => pos += x,
None => break,
}