Skip to content

Conversation

@GauthamBanasandra
Copy link
Member

  • Need to ensure that the destination
    buffer size is greater the source content.
    Truncation could happen otherwise.
  • snprintf returns the size to be written
    when we pass NULL for destination buffer
    and 0 for the size of the destination
    buffer.
  • We will use this information to ensure
    that the source content doesn't exceed
    the destination buffer's size before
    making the call to write.

* Need to ensure that the destination
  buffer size is greater the source content.
  Truncation could happen otherwise.
* snprintf returns the size to be written
  when we pass NULL for destination buffer
  and 0 for the size of the destination
  buffer.
* We will use this information to ensure
  that the source content doesn't exceed
  the destination buffer's size before
  making the call to write.
@GauthamBanasandra
Copy link
Member Author

This PR fixes the warnings reported as part of #2792 in CI run #2792 (comment)

[ 62%] Building C object main/native/libhdfspp/tests/CMakeFiles/libhdfs_threaded_hdfspp_test_shim_static.dir/__/__/libhdfs-tests/expect.c.o
[ 62%] Building C object main/native/libhdfspp/tests/CMakeFiles/libhdfs_threaded_hdfspp_test_shim_static.dir/__/__/libhdfs-tests/test_libhdfs_threaded.c.o
/mnt/c/Users/Gautham/projects/apache/wsl/hadoop/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_threaded.c: In function ‘doTestHdfsOperations’:
/mnt/c/Users/Gautham/projects/apache/wsl/hadoop/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_threaded.c:226:39: warning: ‘/many_files_’ directive output may be truncated writing 12 bytes into a region of size between 1 and 4096 [-Wformat-truncation=]
  226 |       snprintf(filename, PATH_MAX, "%s/many_files_%d", listDirTest, nFile);
      |                                       ^~~~~~~~~~~~
/mnt/c/Users/Gautham/projects/apache/wsl/hadoop/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-tests/test_libhdfs_threaded.c:226:7: note: ‘snprintf’ output between 14 and 4119 bytes into a destination of size 4096
  226 |       snprintf(filename, PATH_MAX, "%s/many_files_%d", listDirTest, nFile);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@hadoop-yetus
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 37s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 1s codespell was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 33m 26s trunk passed
+1 💚 compile 2m 47s trunk passed with JDK Ubuntu-11.0.10+9-Ubuntu-0ubuntu1.20.04
+1 💚 compile 2m 55s trunk passed with JDK Private Build-1.8.0_282-8u282-b08-0ubuntu1~20.04-b08
+1 💚 mvnsite 0m 27s trunk passed
+1 💚 shadedclient 52m 59s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 0m 16s the patch passed
+1 💚 compile 2m 27s the patch passed with JDK Ubuntu-11.0.10+9-Ubuntu-0ubuntu1.20.04
+1 💚 cc 2m 27s hadoop-hdfs-project_hadoop-hdfs-native-client-jdkUbuntu-11.0.10+9-Ubuntu-0ubuntu1.20.04 with JDK Ubuntu-11.0.10+9-Ubuntu-0ubuntu1.20.04 generated 0 new + 11 unchanged - 27 fixed = 11 total (was 38)
+1 💚 golang 2m 27s the patch passed
+1 💚 javac 2m 27s the patch passed
+1 💚 compile 2m 32s the patch passed with JDK Private Build-1.8.0_282-8u282-b08-0ubuntu1~20.04-b08
+1 💚 cc 2m 32s hadoop-hdfs-project_hadoop-hdfs-native-client-jdkPrivateBuild-1.8.0_282-8u282-b08-0ubuntu120.04-b08 with JDK Private Build-1.8.0_282-8u282-b08-0ubuntu120.04-b08 generated 0 new + 11 unchanged - 27 fixed = 11 total (was 38)
+1 💚 golang 2m 32s the patch passed
+1 💚 javac 2m 32s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 mvnsite 0m 20s the patch passed
+1 💚 shadedclient 13m 14s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 31m 44s hadoop-hdfs-native-client in the patch passed.
+1 💚 asflicense 0m 34s The patch does not generate ASF License warnings.
107m 3s
Subsystem Report/Notes
Docker ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-2853/1/artifact/out/Dockerfile
GITHUB PR #2853
Optional Tests dupname asflicense compile cc mvnsite javac unit codespell golang
uname Linux 206a7b3b2ed3 4.15.0-60-generic #67-Ubuntu SMP Thu Aug 22 16:55:30 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 1f46f98
Default Java Private Build-1.8.0_282-8u282-b08-0ubuntu1~20.04-b08
Multi-JDK versions /usr/lib/jvm/java-11-openjdk-amd64:Ubuntu-11.0.10+9-Ubuntu-0ubuntu1.20.04 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_282-8u282-b08-0ubuntu1~20.04-b08
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-2853/1/testReport/
Max. process+thread count 607 (vs. ulimit of 5500)
modules C: hadoop-hdfs-project/hadoop-hdfs-native-client U: hadoop-hdfs-project/hadoop-hdfs-native-client
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-2853/1/console
versions git=2.25.1 maven=3.6.3
Powered by Apache Yetus 0.14.0-SNAPSHOT https://yetus.apache.org

This message was automatically generated.

@goiri goiri merged commit 70536ba into apache:trunk Apr 2, 2021
@GauthamBanasandra GauthamBanasandra deleted the fix-snprintf-trunc branch April 2, 2021 17:55
kiran-maturi pushed a commit to kiran-maturi/hadoop that referenced this pull request Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants