[issue1522400] irda socket support

Charles-François Natali report at bugs.python.org
Wed Apr 25 22:57:53 CEST 2012


Charles-François Natali <neologix at free.fr> added the comment:

Actually I think it suffers from the same problem as AF_UNIX: sockaddr_irda->sir_name, like sockaddr_un->sun_path, don't have to be NUL-terminated, and the kernel can return non NUL-terminated strings.
Which means that such code:
        {
            /* regular NULL-terminated string */
            return PyUnicode_DecodeFSDefault(a->sun_path);
        }

or

        return Py_BuildValue("iO&", a->sir_addr,
                                    PyUnicode_DecodeFSDefault, a->sir_name);


can overrung pas sun_path/sir_name, and potentially segfault.
See http://bugs.python.org/issue8372.

What's the simplest way to account for this?
Is there a way to pass PyUnicode_DecodeFSDefault a max length (without having to make an intermediary copy or sir_name, appending a NUL at the end)?

----------

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


More information about the Python-bugs-list mailing list