Skip to content

Instantly share code, notes, and snippets.

@OlivierLaflamme
Created March 22, 2025 03:14
Show Gist options
  • Save OlivierLaflamme/18fce2e049ebfbdbf94278f671bde344 to your computer and use it in GitHub Desktop.
Save OlivierLaflamme/18fce2e049ebfbdbf94278f671bde344 to your computer and use it in GitHub Desktop.
im going to kill myself
--TEST--
Bug #25378 (unserialize() crashes with invalid data)
--FILE--
<?php
var_dump(unserialize("s:-1:\"\";"));
var_dump(unserialize("i:823"));
var_dump(unserialize("O:8:\"stdClass :0:{}"));
var_dump(unserialize("O:8:\"stdClass\"+0:{}"));
var_dump(unserialize("O:1000:\"stdClass\":0:{}"));
var_dump(unserialize("a:2:{i:0;s:2:\"12\":"));
var_dump(unserialize("a:2:{i:0;s:2:\"12\";i:1;s:3000:\"123"));
var_dump(unserialize("a:2:{i:0;s:2:\"12\"+i:1;s:3:\"123\";}"));
var_dump(unserialize("a:2:{i:0;s:2:\"12\";i:1;s:3:\"123\";"));
var_dump(unserialize("s:3000:\"123\";"));
var_dump(unserialize("s:3000:\"123"));
var_dump(unserialize("s:3:\"123;"));
var_dump(unserialize("s:0:\"123\";"));
?>
--EXPECTF--
Warning: unserialize(): Error at offset 0 of 8 bytes in %s on line %d
bool(false)
Warning: unserialize(): Error at offset 0 of 5 bytes in %s on line %d
bool(false)
Warning: unserialize(): Error at offset 13 of 19 bytes in %s on line %d
bool(false)
Warning: unserialize(): Error at offset 14 of 19 bytes in %s on line %d
bool(false)
Warning: unserialize(): Error at offset 2 of 22 bytes in %s on line %d
bool(false)
Warning: unserialize(): Error at offset 17 of 18 bytes in %s on line %d
bool(false)
Warning: unserialize(): Error at offset 24 of 33 bytes in %s on line %d
bool(false)
Warning: unserialize(): Error at offset 17 of 33 bytes in %s on line %d
bool(false)
Warning: unserialize(): Error at offset 32 of 32 bytes in %s on line %d
bool(false)
Warning: unserialize(): Error at offset 2 of 13 bytes in %s on line %d
bool(false)
Warning: unserialize(): Error at offset 2 of 11 bytes in %s on line %d
bool(false)
Warning: unserialize(): Error at offset 8 of 9 bytes in %s on line %d
bool(false)
Warning: unserialize(): Error at offset 5 of 10 bytes in %s on line %d
bool(false)
===========================
--TEST--
Bug #60909 (custom error handler throwing Exception + fatal error = no shutdown function).
--FILE--
<?php
register_shutdown_function(function(){echo("\n\n!!!shutdown!!!\n\n");});
set_error_handler(function($errno, $errstr, $errfile, $errline){
echo "error($errstr)";
throw new Exception("Foo");
});
require 'notfound.php';
?>
--EXPECTF--
error(require(notfound.php): Failed to open stream: %s)
Fatal error: Uncaught Exception: Foo in %sbug60909_1.php:5
Stack trace:
#0 %s(%d): {closure:%s:%d}(2, 'require(notfoun...', '%s', 8)
#1 %sbug60909_1.php(8): require()
#2 {main}
thrown in %sbug60909_1.php on line 5
!!!shutdown!!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment