From 4936502428f0de2d6be43fd65fd0f77a148d73a0 Mon Sep 17 00:00:00 2001 From: Mihai Patrascoiu Date: Wed, 13 Jun 2018 12:04:27 +0200 Subject: [PATCH] Prevent issue in scenario where stat request returns larger size than the actual read request --- src/XrdHttp/XrdHttpReq.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/XrdHttp/XrdHttpReq.cc b/src/XrdHttp/XrdHttpReq.cc index 233a6d4cde7..b8c7d9e4b4e 100644 --- a/src/XrdHttp/XrdHttpReq.cc +++ b/src/XrdHttp/XrdHttpReq.cc @@ -1803,6 +1803,15 @@ int XrdHttpReq::PostProcessHTTPReq(bool final_) { // Close() if this was the third state of a readv, otherwise read the next chunk if ((reqstate == 3) && (ntohs(xrdreq.header.requestid) == kXR_readv)) return 1; + // Prevent scenario where data is expected but none is actually read + // E.g. Accessing files which return the results of a script + if ((ntohs(xrdreq.header.requestid) == kXR_read) && + (reqstate > 2) && (iovN == 0)) { + TRACEI(REQ, "Stopping request because more data is expected " + "but no data has been read."); + return -1; + } + // If we are here it's too late to send a proper error message... if (xrdresp == kXR_error) return -1;