Address glibc memory error for some I/O routines

A number of I/O tests have been failing in nightly testing on a range of configurations.
These tests pass for typical efforts to reproduce; eventually I determined that the failure
is triggered by a long argv[0].

The error turned out to be in the utility sys_getcwd() which relies on the clunky posix
function get_cwd().  The QIO code needs to provide a buffer to get_cwd() without
knowing how large the buffer needs to be. This is resolved by trying calls with buffers
of increasing size using realloc() to expand the buffer each time.  Unfortunately the
original code did not correctly capture the result of the realloc().

Once this was found and fixed I scanned all of runtime/qio and found a second instance
of this error in code that was likely to have started as an unfortunate cut/paste.

Compiled on Mac/Linux.
Ran on several tests that had been failing and now pass.
Ran on standard regression suite.

Did one test run where I made the original buffer 8 bytes long with an input
path of over 150.