Fix the length of data retrieved from the buffer