You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
char buffer in function posix_getcwdu should not be fix length #51066
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2010-07-20.18:58:57.419>created_at=<Date2009-09-02.02:57:44.744>labels= ['extension-modules', 'type-bug']
title='char buffer in function posix_getcwdu should not be fix length'updated_at=<Date2010-07-20.18:58:57.416>user='https://bugs.python.org/boya'
This issue is similar to bpo-2722 (http://bugs.python.org/issue2722#),
where the char buffer support that the path string has
not fixed length in the function posix_getcwd().
In the function posix_getcwdu(), the char buffer is still fix length. But
I think the same change should also apply to this function. A patch is
attached to allow the char buffer in posix_getcwdu() to be not fixed
length.
The "#ifdef MS_WINDOWS" is not a the right place in posix_getcwdu(): buf and
res are declared but unused, and there is dead code on Windows.
The patch only fixes the UNIX implementation, not the Windows
implementation.
In the py3k branch, bytes and unicode versions of getcwd are factorized in a
common function. The same should be done in python trunk.
boya commented on Sep 10, 2009
boyamannequin
MannequinAuthor
More actions
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(sizeofwbuf/ sizeofwbuf[0], wbuf);
if (len >= sizeofwbuf/ sizeofwbuf[0]) {
wbuf2=malloc(len*sizeof(wchar_t));
if (wbuf2)
len=GetCurrentDirectoryW(len, wbuf2);
}
skrah commented on Jul 20, 2010
skrahmannequin
Mannequin
More actions
I'm marking this as a duplicate of bpo-9246. It's better to change
py3k and 2.7 in sync. The patches here will not be lost.
Activity
boya commentedon Sep 2, 2009
This issue is similar to bpo-2722 (http://bugs.python.org/issue2722#),
where the char buffer support that the path string has
not fixed length in the function posix_getcwd().
In the function posix_getcwdu(), the char buffer is still fix length. But
I think the same change should also apply to this function. A patch is
attached to allow the char buffer in posix_getcwdu() to be not fixed
length.
vstinner commentedon Sep 7, 2009
Your patch is mixing tabs and spaces :-/
A "free(tmpbuf);" is missing in "if (res == NULL) return posix_error();".
vstinner commentedon Sep 7, 2009
The "#ifdef MS_WINDOWS" is not a the right place in posix_getcwdu(): buf and
res are declared but unused, and there is dead code on Windows.
The patch only fixes the UNIX implementation, not the Windows
implementation.
In the py3k branch, bytes and unicode versions of getcwd are factorized in a
common function. The same should be done in python trunk.
boya commentedon Sep 10, 2009
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:
skrah commentedon Jul 20, 2010
I'm marking this as a duplicate of bpo-9246. It's better to change
py3k and 2.7 in sync. The patches here will not be lost.