Fix an overflow in r_buf_read