Enforce correct packet lengths

Zero length messages and messages shorter than the expected length
should be rejected. The expected length is the IPMI Msg Length from the
IPMI session header.

Tested:
  # send a zero-length RMCP1.5 packet and a zero-length RMCP2.0 packet
  # RMCP 1.5
  echo -ne "\x06\x00\xff\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
      | nc -w 1 -u $HOST_IP 623
  # RMCP 2.0
  echo -ne "\x06\x00\xff\x07\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
      | nc -w 1 -u $HOST_IP 623

  # send a truncated 255-byte RMCP1.5 packet and a zero-length RMCP2.0 packet
  # RMCP 1.5
  echo -ne "\x06\x00\xff\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff" \
      | nc -w 1 -u $HOST_IP 623
  # RMCP 2.0
  echo -ne "\x06\x00\xff\x07\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x00" \
      | nc -w 1 -u $HOST_IP 623

  After each packet sent, verify that netipmid did not crash.

Change-Id: Iec63bae7619e0d3274894e4d98d1f1fb7f082ed6
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
1 file changed