diff options
author | Colin Snover | 2017-09-24 13:10:45 +0800 |
---|---|---|
committer | Colin Snover | 2017-10-29 13:18:37 -0500 |
commit | 37459bc6c17a69defc0d6d1f568dcd0261c78511 (patch) | |
tree | 97bcb791e55a75d9d3585332b377b887436b9b0c /common/updates.cpp | |
parent | 4233156505a73a2990aa4245cf2a3b356c88dc17 (diff) | |
download | scummvm-rg350-37459bc6c17a69defc0d6d1f568dcd0261c78511.tar.gz scummvm-rg350-37459bc6c17a69defc0d6d1f568dcd0261c78511.tar.bz2 scummvm-rg350-37459bc6c17a69defc0d6d1f568dcd0261c78511.zip |
SCI: Fix UB in SegManager memcpy/strcpy operations
Passing overlapping buffers to C standard library memcpy, strcpy,
and strncpy is undefined behavior. In SSCI these operations would
perform a forward copy, and most stdlib implementations do the
same, but at least newer Linux glibc on x86 copies bytes in
reverse, so just using the standard library on this platform
results in broken output.
Because SSCI used a blind forward copy instead of memmove for
overlapping copy operations, this patch implements an explicit
forward copy to ensure that overlapping copies continue to operate
the same as in SSCI.
This fixes the Island of Dr. Brain v1.1 flamingo puzzle
(script 185, flamingos::init, localCall 4c3) on platforms that do
not perform forward copy in memcpy/strcpy/strncpy.
Thanks to @moralrecordings for research on this bug and an initial
patch using memmove.
Closes gh-1034.
Diffstat (limited to 'common/updates.cpp')
0 files changed, 0 insertions, 0 deletions