Qualcomm interview question

how to avoid overflow in FIFO design; design a FSM for bit string detect