@@ -475,7 +475,7 @@ PHPAPI int php_random_bytes(void *bytes, size_t size, bool should_throw)
475
475
/* Defer to CryptGenRandom on Windows */
476
476
if (php_win32_get_random_bytes (bytes , size ) == FAILURE ) {
477
477
if (should_throw ) {
478
- zend_throw_exception (zend_ce_exception , "Failed to retrieve randomness from the operating system (BCryptGenRandom)" , 0 );
478
+ zend_throw_exception (random_ce_Random_RandomException , "Failed to retrieve randomness from the operating system (BCryptGenRandom)" , 0 );
479
479
}
480
480
return FAILURE ;
481
481
}
@@ -488,7 +488,7 @@ PHPAPI int php_random_bytes(void *bytes, size_t size, bool should_throw)
488
488
*/
489
489
if (CCRandomGenerateBytes (bytes , size ) != kCCSuccess ) {
490
490
if (should_throw ) {
491
- zend_throw_exception (zend_ce_exception , "Failed to retrieve randomness from the operating system (CCRandomGenerateBytes)" , 0 );
491
+ zend_throw_exception (random_ce_Random_RandomException , "Failed to retrieve randomness from the operating system (CCRandomGenerateBytes)" , 0 );
492
492
}
493
493
return FAILURE ;
494
494
}
@@ -553,9 +553,9 @@ PHPAPI int php_random_bytes(void *bytes, size_t size, bool should_throw)
553
553
if (fd < 0 ) {
554
554
if (should_throw ) {
555
555
if (errno != 0 ) {
556
- zend_throw_exception_ex (zend_ce_exception , 0 , "Cannot open /dev/urandom: %s" , strerror (errno ));
556
+ zend_throw_exception_ex (random_ce_Random_RandomException , 0 , "Cannot open /dev/urandom: %s" , strerror (errno ));
557
557
} else {
558
- zend_throw_exception_ex (zend_ce_exception , 0 , "Cannot open /dev/urandom" );
558
+ zend_throw_exception_ex (random_ce_Random_RandomException , 0 , "Cannot open /dev/urandom" );
559
559
}
560
560
}
561
561
return FAILURE ;
@@ -573,9 +573,9 @@ PHPAPI int php_random_bytes(void *bytes, size_t size, bool should_throw)
573
573
close (fd );
574
574
if (should_throw ) {
575
575
if (errno != 0 ) {
576
- zend_throw_exception_ex (zend_ce_exception , 0 , "Error reading from /dev/urandom: %s" , strerror (errno ));
576
+ zend_throw_exception_ex (random_ce_Random_RandomException , 0 , "Error reading from /dev/urandom: %s" , strerror (errno ));
577
577
} else {
578
- zend_throw_exception_ex (zend_ce_exception , 0 , "Error reading from /dev/urandom" );
578
+ zend_throw_exception_ex (random_ce_Random_RandomException , 0 , "Error reading from /dev/urandom" );
579
579
}
580
580
}
581
581
return FAILURE ;
@@ -594,9 +594,9 @@ PHPAPI int php_random_bytes(void *bytes, size_t size, bool should_throw)
594
594
if (read_bytes < size ) {
595
595
if (should_throw ) {
596
596
if (errno != 0 ) {
597
- zend_throw_exception_ex (zend_ce_exception , 0 , "Could not gather sufficient random data: %s" , strerror (errno ));
597
+ zend_throw_exception_ex (random_ce_Random_RandomException , 0 , "Could not gather sufficient random data: %s" , strerror (errno ));
598
598
} else {
599
- zend_throw_exception_ex (zend_ce_exception , 0 , "Could not gather sufficient random data" );
599
+ zend_throw_exception_ex (random_ce_Random_RandomException , 0 , "Could not gather sufficient random data" );
600
600
}
601
601
}
602
602
return FAILURE ;
0 commit comments