Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
libpq+openssl conflict reproduce case
<p>
<?php
$db = parse_url(getenv("DATABASE_URL"));
$sql = "SELECT repeat('a', 160000)";
$c = pg_connect(sprintf("host='%s' port='%s' dbname='%s' user='%s' password='%s' sslmode='require'", $db["host"], $db["port"], substr($db["path"], 1), $db["user"], $db["pass"]));
$r = openssl_pkey_get_public('a');
if(isset($_GET["clear"]))
while ($msg = openssl_error_string())
echo "Cleared OpenSSL error: <code>$msg</code><br />";
if($r = pg_query($sql))
echo "Query OK";
else
echo "Query failed: <code>".pg_last_error($c)."</code>";
?>
</p>
<p>Run query again <a href="<?=$_SERVER["PHP_SELF"]?>?clear=1">with</a> or <a href="<?=$_SERVER["PHP_SELF"]?>">without</a> a workaround (clearing OpenSSL error stack with <code>openssl_error_string()</code> before running a query).</p>
<p>More info: <a href="https://bugs.php.net/bug.php?id=68276">https://bugs.php.net/bug.php?id=68276</a> and <a href="http://www.postgresql.org/message-id/flat/20150224030956.2529.83279@wrigleys.postgresql.org#20150224030956.2529.83279@wrigleys.postgresql.org">http://www.postgresql.org/message-id/flat/20150224030956.2529.83279@wrigleys.postgresql.org</a></p>
<p>Patch: <a href="http://www.postgresql.org/message-id/flat/CAM3SWZSOJ1p-6jE+h8iii6WboBmyFHuJto=S2Fk==y1wLV3pSQ@mail.gmail.com#CAM3SWZSOJ1p-6jE+h8iii6WboBmyFHuJto=S2Fk==y1wLV3pSQ@mail.gmail.com">http://www.postgresql.org/message-id/flat/CAM3SWZSOJ1p-6jE+h8iii6WboBmyFHuJto=S2Fk==y1wLV3pSQ@mail.gmail.com#CAM3SWZSOJ1p-6jE+h8iii6WboBmyFHuJto=S2Fk==y1wLV3pSQ@mail.gmail.com</a></p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment