Azure / azure-sdk-for-php

Microsoft Azure SDK for PHP
http://azure.microsoft.com/en-us/develop/php/
Apache License 2.0
415 stars 276 forks source link

I found bug in function getGuid(). #984

Closed znrk closed 3 years ago

znrk commented 6 years ago

I found bug in function getGuid.

mt_rand(0, 256), // 8 bits for "clock_seq_low"

clock_seq_low must be two-digits hex string, but when mt_rand() returns 256. it will be a three-digits hex string (256 = 0x100). With this don't generate correct GUID. eg; b4d8316b-36ef-4c9d-85100-17fe2ece51ba

please fix, changing mt_rand() max from 256 to 255.

same code wrotein following files; azure-sdk-for-php/examples/vendor/microsoft/windowsazure/WindowsAzure/Common/Internal/Utilities.php azure-sdk-for-php/src/Common/Internal/Utilities.php azure-sdk-for-php/vendor/microsoft/azure-storage/src/Common/Internal/Utilities.php

mkasberg commented 5 years ago

I was able to confirm the bug, and opened a pull request (#988) to fix it.