Skip to content
This repository has been archived by the owner on Apr 13, 2019. It is now read-only.

Partial Message Body #8

Open
greg80303 opened this issue Mar 23, 2016 · 0 comments
Open

Partial Message Body #8

greg80303 opened this issue Mar 23, 2016 · 0 comments

Comments

@greg80303
Copy link

In connector_Forwarder_Metis.c, the function _readPacket is responsible for consuming the available socket buffer to read 0 or more CCNx packets. The first if statement reads the header and then, optionally, the second statement continues and reads the body. The problem lies in the if (returnCode == ReturnCode_Finished) portion of the second statement.

static ReadReturnCode
_readPacket(FwdMetisState *fwd_state)
{
    ReadReturnCode returnCode = ReadReturnCode_PartialRead;

    // are we still reading the header?
    if (fwd_state->nextMessage.remainingReadLength > 0) {
        returnCode = _readPacketHeader(fwd_state);
    }

    // After reading the header, it may be possible to read the body too
    if (returnCode == ReadReturnCode_Finished && fwd_state->nextMessage.remainingReadLength == 0) {
        returnCode = _readPacketBody(fwd_state);
    }

    return returnCode;
}

Let's say we have a partial body read as a result of one call of this function from the parcEvent handler. On the next invocation of this function, due to data being available on the socket fd, we see the problem. fwd_state->nextMessage.remainingReadLength is 0 since the header has already been read and added to the packet buffer. The first if statement is not executed. This leaves the returnCode variable with a value of ReadReturnCode_PartialRead. Now, the second if statement will never be executed to complete the read of the packet body. We end up in an endless loop of parcEvent notifications (since the socket fd is available for reading), but no actual reads of the socket ever take place.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant