Skip to content

PCKPacker: Fix first file being written mis-aligned #107482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2025

Conversation

nikitalita
Copy link
Contributor

cc @bruvzg

In #105757 , when we changed the PCK format to have the directory come at the end of the files rather than before, we failed to account for the header size potentially causing misalignment on the first file. The header size is currently 104 bytes, so the default alignment of 32 would be not be respected for the first file. This PR fixes that by padding the header so that the file base starts at an aligned byte.

@nikitalita nikitalita requested a review from a team as a code owner June 13, 2025 09:48
@AThousandShips AThousandShips added this to the 4.5 milestone Jun 13, 2025
@aaronfranke aaronfranke moved this from Unassessed to Release Blocker in 4.x Release Blockers Jun 13, 2025
@bruvzg
Copy link
Member

bruvzg commented Jun 13, 2025

The same should be added to EditorExportPlatform::save_pack():

diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp
index 0ab65408f2..62aca2990b 100644
--- a/editor/export/editor_export_platform.cpp
+++ b/editor/export/editor_export_platform.cpp
@@ -1966,6 +1966,11 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, b
                f->store_32(0); // Reserved.
        }

+       int file_padding = _get_pad(PCK_PADDING, f->get_position());
+       for (int i = 0; i < file_padding; i++) {
+               f->store_8(0);
+       }
+
        uint64_t file_base = f->get_position();
        f->seek(file_base_ofs);

But I'm not sure if adding this padding is relevant on any of the supported platforms.

@nikitalita
Copy link
Contributor Author

Done

@akien-mga akien-mga merged commit ee84a5a into godotengine:master Jun 13, 2025
20 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Release Blocker
Development

Successfully merging this pull request may close these issues.

4 participants