Fix an off-by-one bug in recv_pattern().