-
Bug
-
Resolution: Fixed
-
P4
-
8, 11, 12, 13
-
b10
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8304299 | 11.0.20-oracle | Fairoz Matte | P4 | Resolved | Fixed | b01 |
JDK-8230177 | 11.0.5 | Mikael Vidstedt | P4 | Resolved | Fixed | b05 |
Gcc 8 has strict (and sometimes buggy) tests for strncpy() misuse.
A common pattern in the JDK is:
const size_t not_impl_len = strlen(not_impl);
*str = NEW_C_HEAP_ARRAY(char, not_impl_len+1, mtTracing);
strncpy(*str, not_impl, not_impl_len);
(*str)[not_impl_len] = '\0';
More efficient code that does not cause GCC warnings would use strncpy()
to add the trailing null, resulting in shorter code:
strncpy(*str, not_impl, not_impl_len);
(*str)[not_impl_len] = '\0';
becomes:
strncpy(*str, not_impl, not_impl_len+1);
(found by compiling with GCC 8.1)
A common pattern in the JDK is:
const size_t not_impl_len = strlen(not_impl);
*str = NEW_C_HEAP_ARRAY(char, not_impl_len+1, mtTracing);
strncpy(*str, not_impl, not_impl_len);
(*str)[not_impl_len] = '\0';
More efficient code that does not cause GCC warnings would use strncpy()
to add the trailing null, resulting in shorter code:
strncpy(*str, not_impl, not_impl_len);
(*str)[not_impl_len] = '\0';
becomes:
strncpy(*str, not_impl, not_impl_len+1);
(found by compiling with GCC 8.1)
- backported by
-
JDK-8230177 Avoid some GCC 8.X strncpy() errors in HotSpot
- Resolved
-
JDK-8304299 Avoid some GCC 8.X strncpy() errors in HotSpot
- Resolved
- duplicates
-
JDK-8205201 Problematic strncpy usage causes compiler warning on Fedora 28
- Closed
- relates to
-
JDK-8219583 Windows build failure after JDK-8214777 (Avoid some GCC 8.X strncpy() errors in HotSpot)
- Resolved
-
JDK-8214776 Avoid GCC 8.X strncpy() errors in JFR code
- Closed
-
JDK-8213153 Clean up GCC 8 errors
- Closed
-
JDK-8232187 Add os::strncpy_s
- Open
(2 relates to)