-
Bug
-
Resolution: Duplicate
-
P4
-
11
/home/pr/sources/jdk/src/hotspot/os/posix/os_posix.cpp: In static member function ‘static int os::create_file_for_heap(const char*)’:
/home/pr/sources/jdk/src/hotspot/os/posix/os_posix.cpp:172:16: error: ‘char* strncpy(char*, const char*, size_t)’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
(void)strncpy(fullname, dir, strlen(dir)+1);
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/pr/sources/jdk/src/hotspot/os/posix/os_posix.cpp:172:38: note: length computed here
(void)strncpy(fullname, dir, strlen(dir)+1);
~~~~~~^~~~~
/home/pr/sources/jdk/src/hotspot/os/posix/os_posix.cpp:173:16: error: ‘char* strncat(char*, const char*, size_t)’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
(void)strncat(fullname, name_template, strlen(name_template));
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
It seems the limit is expected/required to be based on the size of the destination buffer rather than the source buffer. Which superficially seems reasonable, but it depends on whether you have sized your destination buffer based on the source size already. So these warnings could be false positives and we may need to make this a build issue and disable the warnings.
/home/pr/sources/jdk/src/hotspot/os/posix/os_posix.cpp:172:16: error: ‘char* strncpy(char*, const char*, size_t)’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
(void)strncpy(fullname, dir, strlen(dir)+1);
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/pr/sources/jdk/src/hotspot/os/posix/os_posix.cpp:172:38: note: length computed here
(void)strncpy(fullname, dir, strlen(dir)+1);
~~~~~~^~~~~
/home/pr/sources/jdk/src/hotspot/os/posix/os_posix.cpp:173:16: error: ‘char* strncat(char*, const char*, size_t)’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
(void)strncat(fullname, name_template, strlen(name_template));
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
It seems the limit is expected/required to be based on the size of the destination buffer rather than the source buffer. Which superficially seems reasonable, but it depends on whether you have sized your destination buffer based on the source size already. So these warnings could be false positives and we may need to make this a build issue and disable the warnings.
- duplicates
-
JDK-8214777 Avoid some GCC 8.X strncpy() errors in HotSpot
- Resolved
- relates to
-
JDK-8244225 stringop-overflow warning on strncpy call from compile_the_world_in
- Resolved