Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XrdHttp: Prevent loop in scenario where stat request provides larger size than the read request #744

Merged
merged 1 commit into from
Jun 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/XrdHttp/XrdHttpReq.cc
Original file line number Diff line number Diff line change
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