Add bounds check to simple HDLC writer