Page MenuHomePhabricator

[Wilds] Use "random_bytes()" if it is available (after PHP7)
ClosedPublic

Authored by epriestley on Oct 2 2018, 6:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 11, 8:18 AM
Unknown Object (File)
Tue, Apr 2, 8:47 AM
Unknown Object (File)
Tue, Apr 2, 8:47 AM
Unknown Object (File)
Tue, Apr 2, 4:19 AM
Unknown Object (File)
Mon, Apr 1, 4:24 AM
Unknown Object (File)
Sat, Mar 30, 11:32 AM
Unknown Object (File)
Sat, Mar 30, 6:56 AM
Unknown Object (File)
Mar 20 2024, 10:29 PM
Subscribers
None

Details

Summary

Ref T13209. In PHP7 and newer, the function random_bytes() gives us simple access to cryptographic randomness across platforms. Prefer it if it's available.

Notably, the other sources often aren't available on Windows, and particularly aren't available on a clean/default install with modern software versions. So the major motivation is to make things work better out-of-the-box on Windows.

Test Plan

On Windows, saw Filesystem unit tests which call readRandomBytes() now pass.

Diff Detail

Repository
rARC Arcanist
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Harbormaster returned this revision to the author for changes because remote builds failed.Oct 2 2018, 6:08 PM
Harbormaster failed remote builds in B20977: Diff 47135!
epriestley updated this revision to Diff 47136.
  • More correct fix for error message.
epriestley added inline comments.
src/filesystem/Filesystem.php
484

This just printed "s", not "%s".

(Since I think it's unlikely that we'll ever have untrusted, non-technical translators work with this codebase I'm generally inclined to think we should just embed strings like this in the text rather than parameterize them. Embedded strings are simpler for us to work with, avoid mistakes like this one, and it seems unlikely that a translator would incorrectly translate this string into another language by mistake.)

This revision is now accepted and ready to land.Oct 2 2018, 7:20 PM
This revision was automatically updated to reflect the committed changes.