[New-bugs-announce] [issue35071] Canot send real string from c api to module (corrupted string)

Yhojann Aguilera report at bugs.python.org
Thu Oct 25 16:20:14 EDT 2018


New submission from Yhojann Aguilera <yhojann.aguilera at gmail.com>:

The functios like as PyUnicode_FromString use a printf format in char array argument. Example: PyUnicode_FromString("a%22b"); in module interprete the %22 as 22 blank spaces. A double quote in module add a backslash. Poc:

Y try send a string from c++ to python string using:

PyObject* pyString = PyUnicode_FromString("/abc/def.html/a%22.php?abc=&def=%22;%00s%01");
....
PyObject* pyArgs = Py_BuildValue("(z)", pyString);
...
PyObject_CallObject(pFunc, pyArgs);

But in script the string is bad:

function(data):
    print(data)

The result is:

/abc/def.html/a              bogus %pp?abc=&def=                    %;(null)%

----------
components: Library (Lib)
messages: 328484
nosy: Yhojann Aguilera
priority: normal
severity: normal
status: open
title: Canot send real string from c api to module (corrupted string)
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35071>
_______________________________________


More information about the New-bugs-announce mailing list