From a100b84f221cc7ebceafe18b287cf713d02ec8b1 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Wed, 9 Jun 2021 10:48:11 +0200 Subject: [PATCH] issue #282: add extra length check 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 7395e5fe..80150940 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: ")