diff options
author | Daniel Lowe <dlowe@dlowe.net> | 2019-04-21 11:14:17 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2019-04-26 10:41:04 +0200 |
commit | f955276694680695be76dc9bfcf22d19e10613be (patch) | |
tree | 28546d911882797ef523599c1ef28e91e6d8a73a /include | |
parent | 77cc60faf26454e17d21236b7d6ac642f32a22c1 (diff) | |
download | volse-hubzilla-f955276694680695be76dc9bfcf22d19e10613be.tar.gz volse-hubzilla-f955276694680695be76dc9bfcf22d19e10613be.tar.bz2 volse-hubzilla-f955276694680695be76dc9bfcf22d19e10613be.zip |
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.
(cherry picked from commit 9a6531e2a278f7462241ddde7b3e5363d13b5e58)
Diffstat (limited to 'include')
-rwxr-xr-x | include/dba/dba_pdo.php | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/include/dba/dba_pdo.php b/include/dba/dba_pdo.php index 5002f53e7..ef8063428 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'; } |