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

[XrdCl] Be sure to only read the header of kXR_status messages at first #1829

Merged
merged 1 commit into from
Nov 24, 2022
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
19 changes: 12 additions & 7 deletions src/XrdCl/XrdClXRootDTransport.cc
Original file line number Diff line number Diff line change
Expand Up @@ -348,19 +348,24 @@ namespace XrdCl
{
//--------------------------------------------------------------------------
// Retrieve the body
// In case of non kXR_status responses we read all the response, including
// data. For kXR_status responses we first read only the remainder of the
// header. The header must then be unmarshalled, and then a second call of
// GetBody (repeated for suRetry as needed) will read the data.
//--------------------------------------------------------------------------
size_t leftToBeRead = 0;
uint32_t bodySize = 0;
ServerResponseHeader* rsphdr = (ServerResponseHeader*)message.GetBuffer();
if( rsphdr->status != kXR_status )
bodySize = rsphdr->dlen;
else
bodySize = rsphdr->dlen;
if( rsphdr->status == kXR_status )
{
size_t stlen = sizeof( ServerResponseStatus ); // we read everything up to the offset
if( message.GetCursor() < stlen )
bodySize = rsphdr->dlen;
else
if( message.GetCursor() >= bodySize+8 ) // we read everything up to the data[]
{
const size_t stlen = sizeof( ServerResponseStatus );
if( bodySize+8 < stlen )
return XRootDStatus( stError, errInvalidMessage, 0,
"kXR_status: invalid message size." );

ServerResponseStatus *rspst = (ServerResponseStatus*)message.GetBuffer();
bodySize = rspst->hdr.dlen + rspst->bdy.dlen;
}
Expand Down