Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8232187

Add os::strncpy_s

    XMLWordPrintable

    Details

      Description

      Uses of strncpy sometimes trigger gcc warning -Wstringop-truncation. Some have been correct warnings, some have been false positives. It may also be that some uses aren't being warned about but should be, because strncpy can be tricky to use properly. The places where the warnings occur has varied between gcc versions.

      Rather than responding to a different set of complaints from different versions of gcc, we should consider adding os::strncpy_s, modelled on the corresponding C11 function, and replacing uses of strncpy with uses of that function. [Later: A possibly better choice is strscpy; see comments.]

      gcc metabug for -Wstringop-truncation bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88781

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              kbarrett Kim Barrett
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated: