[issue6817] char buffer in function posix_getcwdu should not be fix length

Boya Sun report at bugs.python.org
Thu Sep 10 20:02:03 CEST 2009


Boya Sun <boya.sun at case.edu> added the comment:

Victor,

I corrected both issues of the patch according to your first comment. 

This patch did not fix the Windows implementation. It seems that there
will not be buffer overflow in the Windows implementation, since if the
buffer is small for GetCurrentDirectoryW(), the code allocates a new
buffer for it with enough length by the following code:

        len = GetCurrentDirectoryW(sizeof wbuf/ sizeof wbuf[0], wbuf);
	if (len >= sizeof wbuf/ sizeof wbuf[0]) {
		wbuf2 = malloc(len * sizeof(wchar_t));
		if (wbuf2)
			len = GetCurrentDirectoryW(len, wbuf2);
	}

----------
Added file: http://bugs.python.org/file14874/patch_6817.diff

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


More information about the Python-bugs-list mailing list