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

uniqid() is insufficiently unique on Windows #9

Open
pauln opened this issue Feb 4, 2016 · 1 comment
Open

uniqid() is insufficiently unique on Windows #9

pauln opened this issue Feb 4, 2016 · 1 comment

Comments

@pauln
Copy link
Owner

pauln commented Feb 4, 2016

When processing multiple small PDF files using setSourceData to supply raw PDF data, uniqid() can return the same value on subsequent calls, resulting in the same PDF being processed more than once. There are a couple of options, which require further investigation:

  • Pass true as the second parameter ($more_entropy) to uniqid(), which appears to result in sufficiently unique values, at least in most cases
  • Replace uniqid() with a hash of the input data, which will also allow parser reuse when passing the same data to setSourceData multiple times

The first option is a quick fix, but the second may be more satisfactory - given a hash algorithm with suitable tradeoff between resource consumption and collision probability.

@pauln
Copy link
Owner Author

pauln commented Feb 4, 2016

This issue was discovered from investigation of a weird issue which @gismofx reported by email: attempts to concatenate two single-page PDFs would frequently (but not always) result in the first PDF being doubled up (and the second being skipped). We were able to determine with a bit of investigation that the uniqid() calls were both returning the same value, resulting in the first PDF's parser being reused instead of a new one being initialised.

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

No branches or pull requests

1 participant