Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #358
Bit of a different approach from #441 that should be more maintainable.
Removes VMA macro. Replacements:
VMA_N: Address must have enough space for multiple of a specified non-array type.
VMA_1: Address must have enough space for 1 of a specified non-array type.
VMA_VEC3: Address must have enough space for a vec3_t.
VMA_STR: Argument is an input string. (Not valid for output strings - use VMA_DYN)
VMA_DYN: Argument is an array with a specified maximum output quantity, and the quantity must not be negative. Also checks for arithmetic overflow.
VMA_HACK_AVAILABLE: Compatibility hack for syscalls that output to unbounded char pointer (only PC_SourceFileAndLine). In this case, the available address range is used for QVM, and a fallback number is used for DLLs.
VMA_DYN_SIZED: Argument is an array of type with specified size that includes extra space (used for SV_LocateGameData). Specified size must be at least the size of the element type.
VMA_UNBOUNDED: Unchecked pointer, only used for UnifyWhiteSpaces, which should not be able to expand the string size.
Updated StringReplaceWords, BotReplaceSynonyms, BotReplaceReplySynonyms. Synonym replacement now stops if the destination string would be expanded by the synonym replacement beyond its expected size.
There are a ton of other string handling safety issues in botlib though so it's really not a great situation.
Tested offline and everything seems OK?
After this I will try to get another change to harden the memory access a bit further by forcing there to be a decommitted guard page 2 pages after the VM memory, which will mean that any attempt to access memory >1 page beyond the VM memory space will just page fault and crash the game immediately instead of doing bad things to valid memory.