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

qstrncpy doesn't properly fill in unused destination buffer

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 4.7.0
    • 4.5.3
    • None
    • None
    • At least on windows platforms
    • 298aee0577a45dadf8e30b5bea05224f9e3aa52d

    Description

      qstrncpy() is documented as "[a] safe strncpy() function"

      As such, one would expect it to be an exact work-alike of strncpy(). However, strncpy() infills all unused space in the destination buffer with '\0' from the byte just past the last non-'\0' character of the source string up to the last byte of the destination buffer. qstrncpy() places a '\0' at the end of the string, and at the last byte of the buffer, but leaves all intervening bytes (if any) as they were. This behavior makes qstrncpy() unsuitable for some applications where the defautl strncpy() functionality is expected.

      Attachments

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

        Activity

          People

            albisser Zeno Albisser
            jb4 Jay Burns IV
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes