Comment 6 for bug 297831

Revision history for this message
Harry Hirsch (bzr-unbunt) wrote :

Unfortunatly the chdir_empty.patch doesn't solve the problem. Instead the attached patch solves it.

The problem really was the getcwd() with Linux specific (or better non-POSIX) semantics.

In Solaris-getcwd() the size argument seems to always specify the size of the buffer in which the path name is stored. Contrary to the linux implementation it does not allocate memory as big as necessary if size is zero but instead, if the buf argument is NULL, it allocates a zero-size buffer.

So on Solaris this call to getcwd(NULL, 0) always failed and since the error wasn't caught the chdir()-call in the finally block was made with a zero-length buffer as argument.

The patch replaces the offending getcwd() call with a call that manually allocates a large enough buffer, which is passed as argument to getcwd() (passing NULL to the buf argument seems to be a POSIX extension).

Also it adds error handling to the getcwd() and the corresponding malloc().

Regards,
Harry