1
0
Fork 0
godot/core/io
HP van Braam 240f510fa7 Core ubsan fixes
This fixes UBSAN errors reported by running our testsuite, importing the
TPS demo, and running the TPS demo. I have tried, wherever possible, to
fix issues related to reported issues but not directly reported by UBSAN
because thse code paths just happened to not have been exercised in
these cases.

These fixes apply only to errors reported, and caused by, core/

The following things have been changed:

* Make sure there are no implicit sign changing casts in core.
* Explicitly type enums that are part of a public API such that users of
  the API cannot pass in wrongly-sized values leading to potential stack
  corruption.
* Ensure that memcpy is never called with invalid or null pointers as
  this is undefined behavior, and when the engine is built with
  optimizations turned on leads to memory corruption and hard to debug
  crashes.
* Replace enum values only used as static values with constexpr static
  const values instead. This has no runtime overhead. This makes it so
  that the size of the enums is explicit.
* Make sure that nan and inf is handled consistently in String.
* Implement a _to_int template to ensure that all of the paths use the
  same algorhithm, and correct the negative integer case.
* Changed the way the json serializer precision work, and added tests to
  verify the new behavior. The behavior doesn't quite match master in
  particulary for negative doubles as the original code tried to cast -inf
  to an int. This then led to negative doubles losing all but one of
  their decimal points when serializing. Behavior in GDScript remains
  unchanged.
2024-12-18 14:31:12 +01:00
..
SCsub SCons: Add unobtrusive type hints in SCons files 2024-09-25 09:34:35 -05:00
compression.cpp [Core] Replace `ERR_FAIL_COND` with `ERR_FAIL_NULL` where applicable 2023-09-11 19:45:49 +02:00
compression.h Core ubsan fixes 2024-12-18 14:31:12 +01:00
config_file.cpp Add const lvalue ref to core/* container parameters 2024-02-14 11:20:36 -03:00
config_file.h Add const lvalue ref to core/* container parameters 2024-02-14 11:20:36 -03:00
dir_access.cpp Merge pull request #98812 from bruvzg/macos_bundles_as_file 2024-12-03 14:41:07 -06:00
dir_access.h Core ubsan fixes 2024-12-18 14:31:12 +01:00
dtls_server.cpp Allow ClassDB to create a Object without postinitialization for GDExtension. 2024-08-20 20:19:02 +08:00
dtls_server.h Allow ClassDB to create a Object without postinitialization for GDExtension. 2024-08-20 20:19:02 +08:00
file_access.compat.inc [FileAccess] Return error codes from `store_*` methods. 2024-11-29 23:22:31 +02:00
file_access.cpp Core ubsan fixes 2024-12-18 14:31:12 +01:00
file_access.h Core ubsan fixes 2024-12-18 14:31:12 +01:00
file_access_compressed.cpp Core ubsan fixes 2024-12-18 14:31:12 +01:00
file_access_compressed.h [FileAccess] Return error codes from `store_*` methods. 2024-11-29 23:22:31 +02:00
file_access_encrypted.cpp Core ubsan fixes 2024-12-18 14:31:12 +01:00
file_access_encrypted.h Core ubsan fixes 2024-12-18 14:31:12 +01:00
file_access_memory.cpp Core ubsan fixes 2024-12-18 14:31:12 +01:00
file_access_memory.h [FileAccess] Return error codes from `store_*` methods. 2024-11-29 23:22:31 +02:00
file_access_pack.cpp Add contains_char() for single-character 'contains' calls. 2024-12-06 20:23:35 +01:00
file_access_pack.h [FileAccess] Return error codes from `store_*` methods. 2024-11-29 23:22:31 +02:00
file_access_zip.cpp [FileAccess] Return error codes from `store_*` methods. 2024-11-29 23:22:31 +02:00
file_access_zip.h [FileAccess] Return error codes from `store_*` methods. 2024-11-29 23:22:31 +02:00
http_client.cpp Use `(r)find_char` instead of `(r)find` for single characters 2024-11-17 10:02:18 +01:00
http_client.h Allow ClassDB to create a Object without postinitialization for GDExtension. 2024-08-20 20:19:02 +08:00
http_client_tcp.cpp When calling code has length of string, pass it to parse_utf8 2024-12-01 08:31:22 +01:00
http_client_tcp.h Allow ClassDB to create a Object without postinitialization for GDExtension. 2024-08-20 20:19:02 +08:00
image.cpp Image: More cleanup and reduced code duplication. 2024-12-12 11:52:59 +01:00
image.h Core ubsan fixes 2024-12-18 14:31:12 +01:00
image_loader.cpp Support uid:// in more places 2024-11-16 21:43:18 +01:00
image_loader.h Add 'override' mark to ResourceFormat class 2024-03-25 04:06:34 +08:00
ip.cpp [Core] Improve error messages with `vformat` 2024-10-30 15:55:51 +01:00
ip.h Display `BitField[Enum]` in docs to distinguish from `Enum` 2023-06-15 17:23:02 +03:00
ip_address.cpp Add contains_char() for single-character 'contains' calls. 2024-12-06 20:23:35 +01:00
ip_address.h One Copyright Update to rule them all 2023-01-05 13:25:55 +01:00
json.cpp Core ubsan fixes 2024-12-18 14:31:12 +01:00
json.h Merge pull request #99765 from dalexeev/core-fix-json-from-to-native 2024-12-10 14:15:53 -06:00
logger.cpp Remove confusing USER prefix from script-logged errors 2024-08-27 15:00:48 +01:00
logger.h Strip ANSI escape codes from file logging 2024-04-24 01:02:47 +02:00
marshalls.cpp Core ubsan fixes 2024-12-18 14:31:12 +01:00
marshalls.h Add half precision floating point support to `StreamPeer` 2024-11-12 08:46:52 -03:00
missing_resource.cpp Fix missing resource properties being dropped on save 2024-11-05 11:53:29 -06:00
missing_resource.h Fix missing resource properties being dropped on save 2024-11-05 11:53:29 -06:00
net_socket.cpp One Copyright Update to rule them all 2023-01-05 13:25:55 +01:00
net_socket.h Core ubsan fixes 2024-12-18 14:31:12 +01:00
packed_data_container.cpp Use Core/Scene stringnames consistently 2024-05-13 23:41:07 +02:00
packed_data_container.h Add support for compiling with VS clang-cl toolset 2024-08-28 13:30:44 -05:00
packet_peer.cpp Style: Add `WARNING:` as new comment admonition 2024-09-25 09:44:42 -05:00
packet_peer.h Extract ScriptInstance to simplify includes 2023-09-06 22:54:38 +02:00
packet_peer_dtls.cpp Allow ClassDB to create a Object without postinitialization for GDExtension. 2024-08-20 20:19:02 +08:00
packet_peer_dtls.h Allow ClassDB to create a Object without postinitialization for GDExtension. 2024-08-20 20:19:02 +08:00
packet_peer_udp.cpp CI: Update Linux runners to Ubuntu 24.04 2024-11-10 14:05:27 -06:00
packet_peer_udp.h Add const lvalue ref to core/* container parameters 2024-02-14 11:20:36 -03:00
pck_packer.cpp Core ubsan fixes 2024-12-18 14:31:12 +01:00
pck_packer.h Add ability for PCK patches to remove files 2024-11-11 16:34:37 +01:00
plist.cpp Use `(r)find_char` instead of `(r)find` for single characters 2024-11-17 10:02:18 +01:00
plist.h [macOS/iOS export] Add option to set custom Info.plist data. 2024-01-11 21:05:35 +02:00
remote_filesystem_client.cpp Core ubsan fixes 2024-12-18 14:31:12 +01:00
remote_filesystem_client.h Fix GCC -Wmaybe-uninitialized warnings 2023-08-14 14:35:35 +02:00
resource.cpp [Core] Improve error messages with `vformat` 2024-10-30 15:55:51 +01:00
resource.h Make internal unique scene resource ID deterministic 2024-09-23 15:07:00 +02:00
resource_format_binary.cpp Core ubsan fixes 2024-12-18 14:31:12 +01:00
resource_format_binary.h Universalize UID support in all resource types 2024-11-11 15:59:56 +01:00
resource_importer.cpp Universalize UID support in all resource types 2024-11-11 15:59:56 +01:00
resource_importer.h Core ubsan fixes 2024-12-18 14:31:12 +01:00
resource_loader.cpp Merge pull request #98383 from RandomShaper/deprecate_unsafe_th_rend 2024-12-03 14:40:56 -06:00
resource_loader.h Merge pull request #96590 from reduz/list-directory 2024-11-11 14:18:28 -06:00
resource_saver.cpp [Core] Improve error messages with `vformat` 2024-10-30 15:55:51 +01:00
resource_saver.h Add const lvalue ref to core/* container parameters 2024-02-14 11:20:36 -03:00
resource_uid.cpp Core ubsan fixes 2024-12-18 14:31:12 +01:00
resource_uid.h Core ubsan fixes 2024-12-18 14:31:12 +01:00
stream_peer.cpp Core ubsan fixes 2024-12-18 14:31:12 +01:00
stream_peer.h Add half precision floating point support to `StreamPeer` 2024-11-12 08:46:52 -03:00
stream_peer_gzip.cpp add check for negative buffer_size inside start_(de)compression method. 2024-03-08 17:49:48 +03:00
stream_peer_gzip.h One Copyright Update to rule them all 2023-01-05 13:25:55 +01:00
stream_peer_tcp.cpp FIX: Return if TCP is in STATUS_CONNECTED 2024-04-16 10:32:11 +02:00
stream_peer_tcp.h One Copyright Update to rule them all 2023-01-05 13:25:55 +01:00
stream_peer_tls.cpp Allow ClassDB to create a Object without postinitialization for GDExtension. 2024-08-20 20:19:02 +08:00
stream_peer_tls.h Allow ClassDB to create a Object without postinitialization for GDExtension. 2024-08-20 20:19:02 +08:00
tcp_server.cpp Core: Integrate `Ref::instantiate` where possible 2024-11-10 12:41:26 -06:00
tcp_server.h One Copyright Update to rule them all 2023-01-05 13:25:55 +01:00
translation_loader_po.cpp Use `(r)find_char` instead of `(r)find` for single characters 2024-11-17 10:02:18 +01:00
translation_loader_po.h Core: Do not generate `*.uid` files for JSON, certificates, and translations 2024-12-04 14:26:10 +03:00
udp_server.cpp Reduce and prevent unnecessary random-access to `List` 2024-05-04 16:08:55 +02:00
udp_server.h One Copyright Update to rule them all 2023-01-05 13:25:55 +01:00
xml_parser.cpp [Core] Improve error messages with `vformat` 2024-10-30 15:55:51 +01:00
xml_parser.h Display `BitField[Enum]` in docs to distinguish from `Enum` 2023-06-15 17:23:02 +03:00
zip_io.cpp Add const lvalue ref to core/* container parameters 2024-02-14 11:20:36 -03:00
zip_io.h Add const lvalue ref to core/* container parameters 2024-02-14 11:20:36 -03:00