[New-bugs-announce] [issue15766] _imp.load_dynamic() does crash with non-ASCII path and uses the wrong encoding

STINNER Victor report at bugs.python.org
Wed Aug 22 17:41:23 CEST 2012


New submission from STINNER Victor:

_imp.load_dynamic() use UTF-8 (PyUnicode_FromString) to decode the error message from dlerror(), whereas the locale encoding should be used. The path is decoded from UTF-8, whereas the filesystem encoding should be used.

As a result, error_ob and path can be NULL, whereas Py_DECREF() is used and so Python does crash (SIGSEGV).

Attached patch should avoid a crash, but I'm not sure that it is enough to support non-ASCII path: pathname is "./" is the path is not an absolute path.

PyOS_snprintf(pathbuf, sizeof(pathbuf), "./%-.255s", pathname);
  should maybe be replaced with
pathbytes = PyBytes_FromFormat("./%s", pathname);

----------
components: Tkinter
files: imp.patch
keywords: patch
messages: 168892
nosy: brett.cannon, haypo
priority: normal
severity: normal
status: open
title: _imp.load_dynamic() does crash with non-ASCII path and uses the wrong encoding
type: crash
versions: Python 3.3, Python 3.4
Added file: http://bugs.python.org/file26965/imp.patch

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


More information about the New-bugs-announce mailing list