Skip to content

Commit

Permalink
Prevent issue in scenario where stat request returns larger size than…
Browse files Browse the repository at this point in the history
… the actual read request
  • Loading branch information
mpatrascoiu committed Jun 13, 2018
1 parent 6e788cb commit 4936502
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/XrdHttp/XrdHttpReq.cc
Expand Up @@ -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;

Expand Down

0 comments on commit 4936502

Please sign in to comment.