From cbd2e440fc86fb46da5227240d0bcbe170585271 Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 9 Jun 2021 21:22:57 +0200 Subject: [PATCH] issue #282: add extra length check (#285) work around short/truncated reads by adding an extra length check rather than assuming the read string already has a specific length --- lib/ArangoDBClient/HttpHelper.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ArangoDBClient/HttpHelper.php b/lib/ArangoDBClient/HttpHelper.php index 8ef9e67c..e768f601 100644 --- a/lib/ArangoDBClient/HttpHelper.php +++ b/lib/ArangoDBClient/HttpHelper.php @@ -255,7 +255,10 @@ public static function transfer($socket, $request, $method) // 12 = minimum offset (i.e. strlen("HTTP/1.1 xxx") - // after that we could see "content-length:" - $pos = stripos($result, 'content-length: ', 12); + $pos = false; + if (strlen($result) > 12) { + $pos = stripos($result, 'content-length: ', 12); + } if ($pos !== false) { $contentLength = (int) substr($result, $pos + 16, 10); // 16 = strlen("content-length: ")