make sure tmp buffer is appropriately sized.