freeipmi-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Freeipmi-devel] checking chksums, possible framework change needed??


From: Albert Chu
Subject: [Freeipmi-devel] checking chksums, possible framework change needed??
Date: Tue, 18 Nov 2003 13:45:02 -0800

Hey AB,

In your ipmi-wrapper.c code, you do checksum checks like the following:

if (pkt.chksum != ipmi_chksum((u_int8_t *) &pkt.msg.rs,
                  (sizeof (pkt.msg.rs) + sizeof(pkt.data))))
{
     // yell and scream about checksum errors
}

However this is incorrect.  The reason is that on a completion code
error (for example, a bad username or bad password error), response data
may not be returned.  Thus, the packet received will be smaller than
expected.  Thus, the response packet's checksum field may not be copied
into the pkt.chksum field properly.  And the above chksum check bombs.

For example, a get_session_challenge_response is 42 bytes (rmcp +
session + rs_msg + data + chksum).  However, if you passed a bad
username during the get_session_challenge_request command, the response
will only be 23 bytes (the only response data is the completion code, no
session_id or challenge string is returned).  Therefore, calling
ipmi_chksum using your above example will fail, when in fact, it
shouldn't fail.  The checksums are probably fine, its the completion
code that is the problem.

I think the correct way is to do this is as follows:

len = ipmi_recvfrom(fd, &rmcp_hdr, &ipmi_pkt, sizeof(ipmi_pkt));
if (len <= 0)
   // blah blah

if (ipmi_response_chksum(&ipmi_pkt.msg.rs, len) == 0)
   // blah blah yell and scream

I think the ipmi_recvfrom should return the length of data stored
in the ipmi_pkt buffer.  Then, the ipmi_chksum_response function
assumes the last byte of the buffer passed in is the checksum field.

Let me know what you think ...

Al

--
Albert Chu
address@hidden
Lawrence Livermore National Laboratories





reply via email to

[Prev in Thread] Current Thread [Next in Thread]