diff options
author | David Nikdel <david.nikdel@gmail.com> | 2023-09-03 18:14:30 -0400 |
---|---|---|
committer | David Nikdel <david.nikdel@gmail.com> | 2023-09-03 18:14:30 -0400 |
commit | 067807c1cb7a13624c1d226f301b0431c6edec87 (patch) | |
tree | d807266ce3cb6d96667cfe94a6b02ab5501f6807 | |
parent | fa3428ff25bc577d2a3433090478a6d615567056 (diff) | |
download | redot-engine-067807c1cb7a13624c1d226f301b0431c6edec87.tar.gz |
Remove nondeterminism in pck_packer
PCK files (like other build products) should be deterministic based on their inputs. Removed calls to Math::rand() that are being used to generate padding.
Looks like these were introduced as part of adding encryption support, but the padding being random does not have any cryptographic significance. This can be trivially inferred since file blocks that happen to be aligned don't get padding anyway.
If there's a desire to indroduce something that functions as a nonce it should probably be added explicitly and only if encryption is enabled.
remove Math::rand() calls in editor_export_platform.cpp
follow up to make consistent with pck_packer
-rw-r--r-- | core/io/pck_packer.cpp | 4 | ||||
-rw-r--r-- | editor/export/editor_export_platform.cpp | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp index 9b49cc3d8c..a7c715c318 100644 --- a/core/io/pck_packer.cpp +++ b/core/io/pck_packer.cpp @@ -205,7 +205,7 @@ Error PCKPacker::flush(bool p_verbose) { int header_padding = _get_pad(alignment, file->get_position()); for (int i = 0; i < header_padding; i++) { - file->store_8(Math::rand() % 256); + file->store_8(0); } int64_t file_base = file->get_position(); @@ -244,7 +244,7 @@ Error PCKPacker::flush(bool p_verbose) { int pad = _get_pad(alignment, file->get_position()); for (int j = 0; j < pad; j++) { - file->store_8(Math::rand() % 256); + file->store_8(0); } count += 1; diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp index 1ea5fbc759..208451acce 100644 --- a/editor/export/editor_export_platform.cpp +++ b/editor/export/editor_export_platform.cpp @@ -236,7 +236,7 @@ Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_pa int pad = _get_pad(PCK_PADDING, pd->f->get_position()); for (int i = 0; i < pad; i++) { - pd->f->store_8(Math::rand() % 256); + pd->f->store_8(0); } // Store MD5 of original file. @@ -1659,7 +1659,7 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b int header_padding = _get_pad(PCK_PADDING, f->get_position()); for (int i = 0; i < header_padding; i++) { - f->store_8(Math::rand() % 256); + f->store_8(0); } uint64_t file_base = f->get_position(); |