libstd: refine dynamic memory allocations in os::getcwd() and os::change_dir()

Similar worries about passing in the whole uninitialized buffer here as I had above, perhaps `getcwd_aux` could call `.as_slice()` with the return value and return that?