ddnet/src/test
Robert Müller 02f60421f9 Add validation for StrToInts and IntsToStr
Add strict validation for `StrToInts` function. Because this function should only be used with trusted internal strings, assertions are added to ensure that the string is not truncated. Some buffer sizes are adjusted accordingly, so truncation cannot happen.

Add less strict validation for `IntsToStr` function. An additional argument specifying the size of the output buffer is added to assert that the size of the output buffer is sufficient. However, because this function is used to decode data sent by the server and read from maps and ghosts, invalid input data should never result in crashes or invalid UTF-8 strings. The function will now unpack an empty string and return `false`, if the string contains invalid UTF-8.

The inline definition of the functions is not wanted, because it requires adding a `system.h` include in `gamecore.h`. Therefore the tools now have to depend on game-shared, which previously only worked because the functions were inline.

Tests are added to ensure the function still behaves the same as before for valid inputs and correctly handles invalid inputs.
2024-03-10 12:49:56 +01:00
..
aio.cpp Add override in code behind CONF_DISCORD, disable clang-tidy check 2022-05-18 01:19:35 +02:00
bezier.cpp Move src/game/bezier.cpp/h to src/base/bezier.cpp/h 2022-09-24 20:53:59 +02:00
blocklist_driver.cpp make tests work 2021-05-06 13:10:39 +02:00
bytes_be.cpp Use sizeof(int32_t) instead of 4 2023-02-11 13:59:08 +01:00
color.cpp Add test to ensure that color_casts keep the same alpha value 2023-06-04 23:37:18 +02:00
compression.cpp Use traditional casts instead of functional-style casts 2022-11-06 11:52:21 +01:00
csv.cpp Make less headers depend on <base/system.h> 2023-12-11 23:52:23 +01:00
datafile.cpp Rename all variables for strict camel-casing of abbreviations 2024-03-05 15:44:09 +01:00
fs.cpp Add fs_split_file_extension to separate filename and extension 2023-06-25 21:51:36 +02:00
git_revision.cpp Use EXPECT_* rather than ASSERT_* in tests 2019-03-12 02:06:54 +01:00
hash.cpp Add tests for overloaded hash operators, use operator instead 2022-11-12 20:36:38 +01:00
huffman.cpp Add tests for Huffman compression 2022-10-25 14:04:50 +02:00
io.cpp Fix files not being truncated when opening for writing on Windows 2024-01-06 15:32:21 +01:00
jobs.cpp Allow background jobs to be aborted, refactoring 2024-02-25 17:03:45 +01:00
json.cpp Remove /modhelp (fixes #1401) 2018-12-12 10:05:44 +01:00
jsonwriter.cpp Include limits instead of climits 2024-01-11 22:24:37 +01:00
linereader.cpp Make less headers depend on <base/system.h> 2023-12-11 23:52:23 +01:00
mapbugs.cpp Remove code for CRC in most places, except where needed for net compat 2020-10-14 17:08:58 +02:00
math.cpp Fix inaccurate envelope point value rounding 2023-11-10 19:11:10 +01:00
memory.cpp Don't use Mersenne Twister 2023-11-18 22:55:17 +01:00
name_ban.cpp Refactor name bans, move code to separate class CNameBans 2023-11-25 22:28:54 +01:00
net.cpp Run unit tests with sanitizers (fixes #6205) 2022-12-30 23:35:22 +01:00
netaddr.cpp Support master server address format in client 2023-08-04 12:32:02 +02:00
os.cpp Merge #6429 2023-05-14 09:24:54 +00:00
packer.cpp Add tests for packer error handling 2023-05-03 19:13:39 +02:00
prng.cpp Fix modernize-loop-convert in tests 2022-07-10 21:42:57 +02:00
score.cpp Rename all variables for strict camel-casing of abbreviations 2024-03-05 15:44:09 +01:00
secure_random.cpp Declare variables as const when possible 2022-11-29 23:32:32 +01:00
serverbrowser.cpp Allow background jobs to be aborted, refactoring 2024-02-25 17:03:45 +01:00
serverinfo.cpp Remove unused parts of the new serverinfo 2021-05-27 21:48:10 +02:00
str.cpp Add validation for StrToInts and IntsToStr 2024-03-10 12:49:56 +01:00
strip_path_and_extension.cpp Add testing infrastructure for teehistorian 2017-09-28 02:03:30 +02:00
swap_endian.cpp Add tests and documentation for swap_endian function 2023-10-14 13:29:24 +02:00
teehistorian.cpp Rename all variables for strict camel-casing of abbreviations 2024-03-05 15:44:09 +01:00
test.cpp Fix test filenames when using typed tests 2023-07-25 15:05:25 +02:00
test.h test: Make it easier to generate multiple temporary filenames 2023-07-25 15:05:24 +02:00
thread.cpp Add CLock wrapper for std::mutex to replace lock_* functions 2023-11-11 00:04:57 +01:00
timestamp.cpp Fix crash on editor autosave 2024-01-02 23:38:41 +01:00
unix.cpp Add very basic test for Unix sockets 2017-12-20 16:56:44 +01:00
uuid.cpp Allow ParseUuid to report errors and add tests 2021-01-23 01:21:20 +01:00