Before calling PKL_ReplyLength() check that the packet has full header.
This didn't change the outcome of the test if the packet was shorter as
the invalid result from PKL_ReplyLength() was either larger than length
of the packet or smaller than header length, failing the length check in
both cases.
} else {
read_length = recvfrom_status;
- expected_length = PKL_ReplyLength(reply);
+ if (read_length >= offsetof(CMD_Reply, data)) {
+ expected_length = PKL_ReplyLength(reply);
+ } else {
+ expected_length = 0;
+ }
bad_length = (read_length < expected_length ||
expected_length < offsetof(CMD_Reply, data));