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

QSettings Windows: Reading REG_SZ without terminating \0 delivers garbage

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.6
    • 5.5.0
    • Core: I/O
    • None
    • Windows 7

    Description

      Somehow it is possible to put a REG_SZ into the windows registry without terminating \0 characters.

      We have this bug in one rare case where a device driver puts its device file name into the registry. regedit will show the string correctly, also regedt32.exe.
      With regedt32.exe you can clearly see that the binary information of the string does not contain two trailing 00 00 bytes.

      When reading this String with QSettings, Qt will give you the string with garbage appended because the string is not correctly terminated.

      Possible fix:
      Change line 488 in qsettings_win.cpp from
      QByteArray data(dataSize, 0);
      to
      QByteArray data(dataSize + 2, 0);

      This will ensure, that the the String has always terminating null characters.

      Attachments

        Activity

          People

            laknoll Lars Knoll
            davidweisgerber David Weisgerber
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: