Malformed input handling

Detect cases where the tag's length field goes beyond the end of the
packet. Also remove redundant check.