Fix read_cert crash when receive fd = -1

This commit is contained in:
LoveSy 2023-09-19 02:21:04 +08:00 committed by John Wu
parent 5fbd3e5c65
commit 927cd571f8

View File

@ -138,6 +138,9 @@ pub fn read_certificate(fd: RawFd, version: i32) -> Vec<u8> {
Err(bad_apk!("cannot find certificate"))
}
if fd == -1 {
return vec![];
}
let mut file = unsafe { File::from_raw_fd(fd) };
let r = inner(&mut file, version).log().unwrap_or(vec![]);
std::mem::forget(file);