bug_61755.phpt 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. --TEST--
  2. Bug #61755 (A parsing bug in the prepared statements can lead to access violations)
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded');
  6. require dirname(__FILE__) . '/config.inc';
  7. require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
  8. PDOTest::skip();
  9. ?>
  10. --FILE--
  11. <?php
  12. require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
  13. $db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
  14. $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  15. echo "NULL-Byte before first placeholder:\n";
  16. $s = $db->prepare("SELECT \"a\0b\", ?");
  17. $s->bindValue(1,"c");
  18. $s->execute();
  19. $r = $s->fetch();
  20. echo "Length of item 0: ".strlen($r[0]).", Value of item 1: ".$r[1]."\n";
  21. echo "\nOpen comment:\n";
  22. try {
  23. $s = $db->prepare("SELECT /*");
  24. $s->execute();
  25. } catch (Exception $e) {
  26. echo "Error code: ".$e->getCode()."\n";
  27. }
  28. echo "\ndone!\n";
  29. ?>
  30. --EXPECTF--
  31. NULL-Byte before first placeholder:
  32. Length of item 0: 3, Value of item 1: c
  33. Open comment:
  34. Error code: 42000
  35. done!