[New-bugs-announce] [issue9185] os.getcwd causes infinite loop on solaris

Zsolt Cserna report at bugs.python.org
Wed Jul 7 10:56:37 CEST 2010


New submission from Zsolt Cserna <zsolt.cserna at morganstanley.com>:

os.getcwd() causes infinite loop on solaris10 when the length of the current directory is greater than 1024 (them limit of the maximum absolute path).

os.getcwd is implemented by a while loop in python, see the function posix_getcwd in posixmodule.c. That while loop loops forever because on solaris it sets errno to ERANGE and res to NULL - even if there will be no positive results from getcwd due to the extra long path.
This infinite while cycle also causes eating up the memory.

I think the solution would be implementing a hard limit for this while loop. It could be either fixed (16k for example), or dymanic: comparing the MAXPATHLEN macro to the size of the allocated buffer and if the size of the buffer is greater than MAXLPATHLEN then raise an OSError exception with the current errno.

That bug was triggered by test_posix unittest.

----------
components: Library (Lib)
messages: 109459
nosy: csernazs
priority: normal
severity: normal
status: open
title: os.getcwd causes infinite loop on solaris
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9185>
_______________________________________


More information about the New-bugs-announce mailing list