From 9a6531e2a278f7462241ddde7b3e5363d13b5e58 Mon Sep 17 00:00:00 2001 From: Daniel Lowe Date: Sun, 21 Apr 2019 11:14:17 +0000 Subject: Fix infinite loop using postgres as backend unescapebin is handed a string in some cases, and it causes an infinite loop when it does. This ensures that the argument is a resource before loading its contents. --- include/dba/dba_pdo.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/include/dba/dba_pdo.php b/include/dba/dba_pdo.php index a70e4a1d7..0279342ec 100755 --- a/include/dba/dba_pdo.php +++ b/include/dba/dba_pdo.php @@ -161,23 +161,17 @@ class dba_pdo extends dba_driver { } function unescapebin($str) { - if($this->driver_dbtype === 'pgsql' && (! is_null($str))) { - $x = ''; - while(! feof($str)) { - $x .= fread($str,8192); + if($this->driver_dbtype === 'pgsql') { + if(gettype($str) === 'resource') { + $str = stream_get_contents($str); } - if(substr($x,0,2) === '\\x') { - $x = hex2bin(substr($x,2)); + if(substr($str,0,2) === '\\x') { + $str = hex2bin(substr($str,2)); } - return $x; - - } - else { - return $str; } + return $str; } - function getdriver() { return 'pdo'; } -- cgit v1.2.3