Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1524

signature.cpp: compiler warnings about potential overflows for sprintf

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Done
    • Affects Version/s: 5.15.2
    • Fix Version/s: None
    • Component/s: Shiboken
    • Labels:
      None
    • Platform/s:
      Linux/X11
    • Commits:
      2f18ab9c93d4fae8d8d7e4d84bd9cd2e7fd22c3d (pyside/pyside-setup/dev) c4067b118b2fdf701ce89603ed4fa0c3bc459364 (pyside/tqtc-pyside-setup/5.15)

      Description

      GCC 10.2 complains about shiboken's signature.cpp:

      ../3rdParty/PySide2/sources/shiboken2/libshiboken/signature/signature.cpp: In function ‘PyObject* adjustFuncName(const char*)’:
      ../3rdParty/PySide2/sources/shiboken2/libshiboken/signature/signature.cpp:512:29: warning: ‘sprintf’ may write a terminating nul past the end of the destination [-Wformat-overflow=]
        512 |         sprintf(_buf, "%s.%s", _path, _name);
            |                             ^
      ../3rdParty/PySide2/sources/shiboken2/libshiboken/signature/signature.cpp:512:16: note: ‘sprintf’ output 2 or more bytes (assuming 202) into a destination of size 201
        512 |         sprintf(_buf, "%s.%s", _path, _name);
            |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../3rdParty/PySide2/sources/shiboken2/libshiboken/signature/signature.cpp:508:33: warning: ‘.fset’ directive writing 5 bytes into a region of size between 0 and 200 [-Wformat-overflow=]
        508 |             sprintf(_buf, "%s.%s.fset", _path, _prop_name);
            |                                 ^~~~~
      ../3rdParty/PySide2/sources/shiboken2/libshiboken/signature/signature.cpp:508:20: note: ‘sprintf’ output 7 or more bytes (assuming 207) into a destination of size 201
        508 |             sprintf(_buf, "%s.%s.fset", _path, _prop_name);
            |             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../3rdParty/PySide2/sources/shiboken2/libshiboken/signature/signature.cpp:506:30: warning: ‘.__dict__['’ directive writing 11 bytes into a region of size between 1 and 201 [-Wformat-overflow=]
        506 |             sprintf(_buf, "%s.__dict__['%s'].fset", _path, _prop_name);
            |                              ^~~~~~~~~~~
      ../3rdParty/PySide2/sources/shiboken2/libshiboken/signature/signature.cpp:506:20: note: ‘sprintf’ output 19 or more bytes (assuming 219) into a destination of size 201
        506 |             sprintf(_buf, "%s.__dict__['%s'].fset", _path, _prop_name);
            |             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      

      should this be using `std::string::op+` instead? or is the gnu extension asprintf a choice? or QString API?

        Attachments

        For Gerrit Dashboard: PYSIDE-1524
        # Subject Branch Project Status CR V

          Activity

            People

            Assignee:
            ctismer Christian Tismer
            Reporter:
            milianw Milian Wolff
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes