Make sure buffer has proper length.