Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-15922

Use memcpy for copying non-null terminated string in jni_helper.c

    XMLWordPrintableJSON

Details

    • Reviewed

    Description

      We currently get a warning while compiling HDFS native client -

      [WARNING]     inlined from 'wildcard_expandPath' at /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2792/src/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/jni_helper.c:427:21,
      [WARNING] /usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: '__builtin_strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
      [WARNING] /home/jenkins/jenkins-home/workspace/hadoop-multibranch_PR-2792/src/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/jni_helper.c:402:43: note: length computed here
      

      The scenario here is such that the copied string is deliberately not null terminated, since we want to insert a PATH_SEPARATOR ourselves. The warning reported by strncpy is valid, but not applicable in this scenario. Thus, we need to use memcpy which doesn't mind if the string is null terminated or not.

      Attachments

        Issue Links

          Activity

            People

              gaurava Gautham Banasandra
              gaurava Gautham Banasandra
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 20m
                  1h 20m