Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-8384

QTemporaryFile bug regarding filename generation

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • Some future release
    • 4.5.0, 4.5.1, 4.5.2, 4.5.3, 4.6.0, 4.6.1, 4.6.2
    • Core: I/O
    • None
    • Windows 7, Qt 4.6

    Description

      QTemporaryFile contains a subtle bug regarding filename generation on Windows, which can cause it to fail randomly under certain circumstances.
      The bug has occured on our workstation twice.

      Background:

      On Windows getpid() is implemented in CRT as follows:

      int _getpid (void)
      {
      return (int)GetCurrentProcessId();
      }

      Please note the signature of GetCurrentProcessId() :

      DWORD WINAPI GetCurrentProcessId(void);

      Therefore due to the aforementioned cast of DWORD to int, getpid() can return values that are negative on Windows

      Please note how the _gettemp() function threats the output of getpid() in this formula:

      while (trv >= path && *trv == 'X' && pid != 0)

      { *trv-- = (pid % 10) + '0'; pid /= 10; }

      In case of negative pid, trv array will be filled with non-digit ascii characters.

      The fix is simple - before the loop check if pid is negative and make it non-negative.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            biochimia João Abecasis
            marcinw Marcin W.
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes