-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also reject negative format values in APCuIterator
This would affect applications that accidentally or deliberately pass in negative values for $format (e.g. PHP_INT_MIN on 64-bit builds) The apc_error macro surprisingly calls php_verror, which is a fatal error. Switch this to zend_throw_error instead - this still supports PHP 8.0 so ValueError is too new.
- Loading branch information
1 parent
eb6b9bd
commit 2e79183
Showing
5 changed files
with
51 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--TEST-- | ||
APC: APCIterator throws for invalid flags | ||
--SKIPIF-- | ||
<?php | ||
require_once(dirname(__FILE__) . '/skipif.inc'); | ||
if (PHP_INT_SIZE == 4) echo "skip 64-bit only\n"; | ||
?> | ||
--INI-- | ||
apc.enabled=1 | ||
apc.enable_cli=1 | ||
--FILE-- | ||
<?php | ||
foreach ([[null, -1], [null, PHP_INT_MAX], ['/invalidRegex'], [null, 0, -1]] as $args) { | ||
try { | ||
var_dump(new APCuIterator(...$args)); | ||
} catch (Throwable $e) { | ||
printf("Caught %s: %s\n", get_class($e), $e->getMessage()); | ||
} | ||
} | ||
foreach ([[[]], 4.2, new stdClass()] as $delete) { | ||
try { | ||
apcu_delete($delete); | ||
} catch (Throwable $e) { | ||
printf("Caught %s: %s\n", get_class($e), $e->getMessage()); | ||
} | ||
} | ||
?> | ||
--EXPECTF-- | ||
Caught Error: APCUIterator format is invalid | ||
Caught Error: APCUIterator format is invalid | ||
|
||
Warning: APCUIterator::__construct(): No ending delimiter '/' found in %s on line 4 | ||
Caught Error: Could not compile regular expression: /invalidRegex | ||
Caught Error: APCUIterator chunk size must be 0 or greater | ||
|
||
Warning: apcu_delete(): apcu_delete() expects a string, array of strings, or APCUIterator instance in %s on line 11 | ||
|
||
Warning: apcu_delete(): apcu_delete() expects a string, array of strings, or APCUIterator instance in %s on line 11 | ||
|
||
Warning: apcu_delete(): apcu_delete object argument must be an instance of APCUIterator. in %s on line 11 |