Skip to content

Commit

Permalink
Remain in bounds of patch symbols
Browse files Browse the repository at this point in the history
Regarding transient NPCs and new/modified infos
  • Loading branch information
szapp committed Feb 26, 2021
1 parent 6a0d9ef commit 7751f5f
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/exec/misc.asm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ setVobToTransient:
cmp esi, eax
jl .cleanup

mov ecx, esp ; Same for ending divider
push char_ndivider2_symb
call zSTRING__zSTRING
addStack 4
push ecx
mov ecx, zCParser_parser
call zCParser__GetIndex
addStack 4
test eax, eax
jl .cleanup

cmp esi, eax
jg .cleanup

%if GOTHIC_BASE_VERSION == 1
test BYTE [ebp+0xF5], 0x1 ; zCVob.dontwritetoarchive
%elif GOTHIC_BASE_VERSION == 2
Expand Down Expand Up @@ -224,6 +238,7 @@ ninja_injectInfo:

sub esp, var_total
push esi
push edi

push char_ndivider_symb
lea ecx, [esp+stackoffset+var_string]
Expand All @@ -234,10 +249,23 @@ ninja_injectInfo:
call zCParser__GetIndex
addStack 4
test eax, eax
verifyStackoffset var_total + 4 ; + 0xBC
verifyStackoffset var_total + 2*4
jl .back
mov esi, eax

push char_ndivider2_symb ; Same for ending divider
lea ecx, [esp+stackoffset+var_string]
call zSTRING__operator_eq
addStack 4
push ecx
mov ecx, zCParser_parser
call zCParser__GetIndex
addStack 4
test eax, eax
verifyStackoffset var_total + 2*4
jl .back
mov edi, eax

push zSTRING_infoClass
mov ecx, zCParser_parser
call zCParser__GetIndex
Expand All @@ -259,10 +287,13 @@ ninja_injectInfo:
call zCParser__GetInstance
addStack 2*4
test eax, eax
verifyStackoffset var_total + 4 ; + 0xBC
verifyStackoffset var_total + 2*4
jl .report
mov esi, eax

cmp esi, edi ; Do not go beyond ending divider
jg .report

lea ecx, [esp+stackoffset+var_string]
call zSTRING___zSTRING
sub esp, 0x8
Expand Down Expand Up @@ -380,6 +411,7 @@ ninja_injectInfo:
.back:
lea ecx, [esp+stackoffset+var_string]
call zSTRING___zSTRING
pop edi
pop esi
add esp, var_total
verifyStackoffset ; 0xBC
Expand Down

0 comments on commit 7751f5f

Please sign in to comment.