CATEGORY: Knuth: Blunder (Thinking the right thing but doing it wrong) REFERENCE: https://www.tug.org/TUGboat/tb10-4/tb26knut.pdf EXPLANATION: When a positive response message arrives, the wrong response payload is extracted: Instead of copying the data from the 'response' buffer, data is copied from the actual target buffer 'm_responsePayload'. CONSEQUENCES: Wrong response payload data. BUGFIX: Use 'm_responsePayload' instead of 'response' in the call to 'memcpy': // Store response payload for later use. m_responsePayloadLength = responseLength - m_requestLength; memcpy(&m_responsePayload[0], &response[m_requestLength], m_responsePayloadLength); REMARKS: The root cause of this bug is most likely the fact that the code is so convoluted. Even reading this code is so onerous that it is hard to maintain focus and attention until one reaches the line containing the blunder. Keeping routines short and avoiding deeply nested 'if' statements ensures that the code is readable and thus reduces the likelihood of such silly mistakes.