Skip to content
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

Memset a UDIF header to ensure archive reproducibility. #5

Merged
merged 1 commit into from Sep 5, 2023

Conversation

PieroV
Copy link

@PieroV PieroV commented Jan 12, 2023

For Tor Browser, we have used the following patch for many years (but with another fork).

I am not sure it is needed also with Mozilla's fork (I see that fb0da70 is already about making dmg deterministic), but memsetting the whole struct anyway seems a good idea to me.

The original author of the patch is Mike Perry.

@PieroV
Copy link
Author

PieroV commented Jan 17, 2023

I have tested the current HEAD of mozilla: it is not deterministic.

The patch I propose fixes the problems.

Copy link

@bhearsum bhearsum left a comment

Choose a reason for hiding this comment

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

(Apologies for the very long delay...this repo is not actively watched.)

This seems pretty sensible to do. For the dmg build case things end up bit for bit identical with and without this patch. I can't seem to make dmg convert work with any ISO I've made so I can't verify that...but having zeros instead of random bits seems like an improvement.

@ncalexan or @glandium - any objections to merging this?

dmg/dmglib.c Outdated
@@ -108,7 +108,8 @@ int buildDmg(AbstractFile* abstractIn, AbstractFile* abstractOut, unsigned int B
ChecksumToken dataForkToken;

UDIFResourceFile koly;

memset(&koly, 0, sizeof(koly));
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need to use memset. You can do UDIFResourceFile koly = {0};

Some of the struct padding and fields contained unitialized memory, which
caused two successive invocations to produce archives that differed in some
bytes.
@PieroV
Copy link
Author

PieroV commented Aug 30, 2023

(Apologies for the very long delay...this repo is not actively watched.)

No worries, thank you for getting to it, we're still interested in upstreaming this patch 😄.

@ncalexan
Copy link
Member

Sorry for delay: yes, we should merge this :)

@bhearsum bhearsum merged commit 2cb30de into mozilla:mozilla Sep 5, 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
4 participants