fix integer overflow in {stream,file}_{get,put}_contents()