mirror of
https://github.com/lifegpc/msg-tool.git
synced 2026-06-06 12:58:45 +08:00
Fix overflow problem
This commit is contained in:
@@ -5,6 +5,7 @@ use crate::scripts::base::*;
|
|||||||
use crate::types::*;
|
use crate::types::*;
|
||||||
use crate::utils::encoding::{decode_to_string, encode_string};
|
use crate::utils::encoding::{decode_to_string, encode_string};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use overf::overflowing;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
/// Circus MES Script Builder
|
/// Circus MES Script Builder
|
||||||
@@ -51,13 +52,13 @@ fn try_parse_header(mut data: MemReaderRef<'_>) -> Result<u8> {
|
|||||||
let head0 = data.read_i32()?;
|
let head0 = data.read_i32()?;
|
||||||
let head1 = data.read_i32()?;
|
let head1 = data.read_i32()?;
|
||||||
if head1 == 0x3 {
|
if head1 == 0x3 {
|
||||||
let offset = head0 as u64 * 0x6 + 0x4;
|
let offset = overflowing!(head0 as u64 * 0x6 + 0x4);
|
||||||
let version = data.peek_u16_at(offset)?;
|
let version = data.peek_u16_at(offset)?;
|
||||||
if ScriptInfo::query_by_version(version).is_some() {
|
if ScriptInfo::query_by_version(version).is_some() {
|
||||||
return Ok(10);
|
return Ok(10);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let offset = head0 as u64 * 0x4 + 0x4;
|
let offset = overflowing!(head0 as u64 * 0x4 + 0x4);
|
||||||
let version = data.peek_u16_at(offset)?;
|
let version = data.peek_u16_at(offset)?;
|
||||||
if ScriptInfo::query_by_version(version).is_some() {
|
if ScriptInfo::query_by_version(version).is_some() {
|
||||||
return Ok(10);
|
return Ok(10);
|
||||||
|
|||||||
Reference in New Issue
Block a user