Add more explicit length checks for get_raw_packet.