fedora 24
integer weakness #16

2

Weakness Breakdown


Definition:

An integer overflow occurs when the answer to an arithmetic operation exceeds the maximum size of the integer type used to store it. The resulting value will appear to have wrapped around the maximum value and started again at the minimum value. This would look like a clock that represents 13:00 by pointing at 1:00. An attacker can use an integer overflow during a buffer length calculation, which results in the allocated buffer being too small to hold the data copied into it, thus causing a buffer overflow.

Warning code(s):

Unless checked, the resulting number can exceed the expected range.

File Name:

SoQt-1.5.0/src/Inventor/Qt/SoQt.cpp

Context:

The highlighted line of code below is the trigger point of this particular Fedora 24 integer weakness.

 #endif

  // This is _extremely_ useful for debugging X errors: activate this
  // code (set the SOQT_XSYNC environment variable on your system to
  // "1") and SOQT_X11_ERRORHANDLER to "1", then rerun the application
  // code in a debugger with a breakpoint set at
  // SoQtP::X11Errorhandler(). Now you can backtrace to the exact
  // source location of the failing X request.
  //
  // Note that we changed this from being opt-out to opt-in, due to
  // what seemed like false negatives, and the fact that bad code from
  // Qt would look like SoQt bugs.
#ifdef Q_WS_X11
  if (SoQtP::X11_ERRORHANDLER == ENVVAR_NOT_INITED) {
    const char * env = SoAny::si()->getenv(SoQtP::SOQT_X11_ERRORHANDLER);
    SoQtP::X11_ERRORHANDLER = env ? atoi(env) : 0;
  }

  if (SoQtP::X11_ERRORHANDLER) {
    // Intervene upon X11 errors.
    SoQtP::previous_handler = (SoQtP_XErrorHandler*)XSetErrorHandler((XErrorHandler)SoQtP::X11Errorhandler);

    if (SoQtP::DEBUG_X11SYNC == ENVVAR_NOT_INITED) {
      const char * env = SoAny::si()->getenv(SoQtP::SOQT_XSYNC);
      SoQtP::DEBUG_X11SYNC = env ? atoi(env) : 0;
      if (SoQtP::DEBUG_X11SYNC) {
        // FIXME: SoDebugError::initClass() not yet invoked! 20021021 mortene.
        SoDebugError::postInfo("SoQt::init", "Turning on X synchronization.");
        Display * d;
#if QT_VERSION < 0x040000 // pre Qt 4
        d = qt_xdisplay();
#else // Qt 4.0.0+
        d = QX11Info::display();
#endif
        XSynchronize(d, True);
      }
    }
  }
#endif // Q_WS_X11

  // This should prove helpful for debugging the pervasive problem
  // under Win32 with loading multiple instances of the same library.
  if (SoQtP::DEBUG_LISTMODULES == ENVVAR_NOT_INITED) {
    const char * env = SoAny::si()->getenv("SOGUI_DEBUG_LISTMODULES");
    SoQtP::DEBUG_LISTMODULES = env ? atoi(env) : 0;
    if (SoQtP::DEBUG_LISTMODULES) { SoAny::listWin32ProcessModules(); }
  }

  SoDB::getSensorManager()->setChangedCallback(SoGuiP::sensorQueueChanged, NULL);
  SoQtP::mainwidget = toplevelwidget; 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.