Torque3D/Engine/source
Ben Payne a88339c219 Fix buffer overflows due to incorrect use of sizeof
A snippet of example code:

UTF16 pszFilter[1024];
...
convertUTF8toUTF16((UTF8 *)mData.mFilters, pszFilter, sizeof(pszFilter));

Since the conversion function is expecting the third parameter to be the
length in 16-bit characters, *not* bytes, this results in the function
writing outside the bounds of the output array.

To make this less likely to happen in the future (I hope), I've provided a
template function that infers the correct size of a static array, so it's
no longer necessary to pass the size in most cases. The sized function has
been renamed with an "N" suffix to hopefully encourage this use.

This bug was caught due to a warning from MSVC about stack corruption
occurring in codeBlock::exec(), after opening a file open dialog twice in
succession. After some hunting, I found that this was due to
FileDialog::Execute() passing incorrect buffer sizes to the conversion
function, which resulted in the function writing a null terminator into
some memory that happened to be in the stack frame of codeBlock::exec()!
2015-01-26 16:52:01 -05:00
..
app PlatformSDL implementation. 2015-01-19 01:17:37 +01:00
cinterface Modified files for SDL2. 2015-01-18 22:52:29 +01:00
collision Minor Improvement to depthSortList.cpp 2014-11-04 06:18:24 -05:00
component Replaced a ton of ConsoleMethods with the DefineConsoleMethod Macro. 2014-11-03 22:42:51 -05:00
console Merge pull request #1035 from bpay/memfixes 2015-01-25 13:42:32 +01:00
core Fix buffer overflows due to incorrect use of sizeof 2015-01-26 16:52:01 -05:00
environment Merge pull request #1035 from bpay/memfixes 2015-01-25 13:42:32 +01:00
forest Merge pull request #1096 from bpay/fix-include-guards 2015-01-24 23:02:13 +01:00
gfx Fix buffer overflows due to incorrect use of sizeof 2015-01-26 16:52:01 -05:00
gui Merge pull request #1035 from bpay/memfixes 2015-01-25 13:42:32 +01:00
i18n Replaced a ton of ConsoleMethods with the DefineConsoleMethod Macro. 2014-11-03 22:42:51 -05:00
lighting Merge branch 'development' into defineconsolemethod 2014-12-26 13:22:16 +11:00
main Fix potential buffer overflows 2014-12-13 16:12:02 -05:00
materials Merge pull request #1035 from bpay/memfixes 2015-01-25 13:42:32 +01:00
math Merge pull request #1096 from bpay/fix-include-guards 2015-01-24 23:02:13 +01:00
navigation NavPath::alwaysRender works the same as NavMesh::alwaysRender. 2014-07-08 14:42:59 +02:00
platform Linux implementation. Include changes for gcc x64. 2015-01-24 22:08:26 +01:00
platformMac Linux implementation. Include changes for gcc x64. 2015-01-24 22:08:26 +01:00
platformPOSIX Fixes for dedicated build on linux. 2014-05-30 12:35:39 +02:00
platformSDL PlatformSDL implementation. 2015-01-19 01:17:37 +01:00
platformWin32 Fix buffer overflows due to incorrect use of sizeof 2015-01-26 16:52:01 -05:00
platformX86UNIX Linux implementation. Include changes for gcc x64. 2015-01-24 22:08:26 +01:00
postFx This just adds some console spam if the PostEffect Texture isn't found. I had a problem back where it was that I mistyped the texture and it took hours to find it. This way you know right away. 2014-11-30 21:47:45 -05:00
renderInstance cleaned up variant of https://github.com/GarageGames/Torque3D/pull/768 alterations: opengl support, in-shader bug-reporting, direction vector fit to material slider-bar. 2014-12-21 14:07:42 -06:00
scene Merge pull request #1035 from bpay/memfixes 2015-01-25 13:42:32 +01:00
sfx Merge pull request #1035 from bpay/memfixes 2015-01-25 13:42:32 +01:00
shaderGen Merge pull request #1118 from Lopuska/patch-17 2015-01-24 22:59:06 +01:00
sim Merge pull request #1035 from bpay/memfixes 2015-01-25 13:42:32 +01:00
T3D Merge pull request #1035 from bpay/memfixes 2015-01-25 13:42:32 +01:00
terrain Merge branch 'development' into defineconsolemethod 2014-12-26 13:22:16 +11:00
testing All unit tests that run now pass. 2014-09-29 11:38:44 +10:00
ts Merge pull request #1035 from bpay/memfixes 2015-01-25 13:42:32 +01:00
util Merge pull request #1035 from bpay/memfixes 2015-01-25 13:42:32 +01:00
windowManager Merge pull request #1035 from bpay/memfixes 2015-01-25 13:42:32 +01:00
ggEndOfLineFix.txt Engine directory for ticket #1 2012-09-19 11:15:01 -04:00