strrpos_offset.phpt 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. --TEST--
  2. strrpos() offset integer overflow
  3. --FILE--
  4. <?php
  5. try {
  6. var_dump(strrpos("t", "t", PHP_INT_MAX+1));
  7. } catch (TypeError $e) {
  8. echo $e->getMessage(), "\n";
  9. }
  10. try {
  11. strrpos(1024, 1024, -PHP_INT_MAX);
  12. } catch (ValueError $exception) {
  13. echo $exception->getMessage() . "\n";
  14. }
  15. try {
  16. strrpos(1024, "te", -PHP_INT_MAX);
  17. } catch (ValueError $exception) {
  18. echo $exception->getMessage() . "\n";
  19. }
  20. try {
  21. strrpos(1024, 1024, -PHP_INT_MAX-1);
  22. } catch (ValueError $exception) {
  23. echo $exception->getMessage() . "\n";
  24. }
  25. try {
  26. strrpos(1024, "te", -PHP_INT_MAX-1);
  27. } catch (ValueError $exception) {
  28. echo $exception->getMessage() . "\n";
  29. }
  30. echo "Done\n";
  31. ?>
  32. --EXPECT--
  33. strrpos(): Argument #3 ($offset) must be of type int, float given
  34. strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
  35. strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
  36. strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
  37. strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
  38. Done