Skip to content

Use a copy of the files when signing with a memorySigner #6

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
Jul 10, 2023

Conversation

rwngallego
Copy link
Contributor

I've found that when using a memorySigner, the original files from the template get corrupted in subsequent calls to the CreateSignedAndZippedPersonalizedPassArchive method. I think that similar to the fileSigner implementation, the memorySigner one should work with a temporary copy of the template files and not affect the original ones. Once the pass is signed and compressed, the temporary copy should be removed, as the fileSigner does.

Given that in Go the maps are passed by reference and not by value, the CreateSignedAndZippedPersonalizedPassArchive method is propagating the manifest.json and signature files calculated in a first call, to the subsequent calls. For example, in a first call, it correctly generates the following manifest.json file and a valid Apple Wallet pass:

{
    "footer.png": "ec95fabe4c282cf0c5acdbc3d58d2adeb2847385",
    "icon.png": "cf6a2cd30798d472f0cb81364d25ba6e895b0cae",
    "[email protected]": "3915ac1b648893731acdd6f53c28cf1179bb72bc",
    "logo.png": "0b9c6f6022ef1031d031cae2f7541173d9039504",
    "pass.json": "cc7095122351b0abdc6724bf4d0dc8a2b582a799"
}

However, In a second call, the manifest.json file would have these extra entries that make the generated pass to be corrupted:

{
    ...
    "manifest.json": "e82e8d958daa0d967c68897e00bf78bd884d1b1a",
    "signature": "ae8f34675a2f5a45a763e221bc8f9c54dc505548"
}

This PR makes a deep copy of the template files and lets the GC deal with removing the copy once the signing/compressing of the files is completed and the copy is not referenced anymore.

Copy link
Owner

@alvinbaena alvinbaena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me. Thank you for finding the bug and making a PR.

@alvinbaena alvinbaena merged commit caa2f11 into alvinbaena:master Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants