Details
-
Bug
-
Resolution: Fixed
-
P4
-
8, 11, 12
-
b23
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8227214 | 11.0.10-oracle | Severin Gehwolf | P4 | Resolved | Fixed | b01 |
JDK-8217003 | 11.0.3 | Severin Gehwolf | P4 | Resolved | Fixed | master |
JDK-8219336 | openjdk8u212 | Severin Gehwolf | P4 | Resolved | Fixed | b01 |
Description
In one fatal error code path, snprintf() is given its output buffer as
an input string.
src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c line 645:
(void)snprintf(buf, sizeof(buf), "JDWP %s", buf);
This was found by compiling with GCC 8.1
$ make all
Building target 'all' in configuration 'linux-x86_64-server-release'
Updating support/modules_libs/jdk.jdwp.agent/libjdwp.so due to 1 file(s)
/home/stooke/dev/openjdk/jdk12/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c: In function ‘jniFatalError’:
/home/stooke/dev/openjdk/jdk12/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c:650:24: error: passing argument 1 to restrict-qualified parameter aliases with argument 4 [-Werror=restrict]
(void)snprintf(buf, sizeof(buf), "JDWP %s", buf);
^~~ ~~~
/home/stooke/dev/openjdk/jdk12/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c: In function ‘jniFatalError.constprop’:
/home/stooke/dev/openjdk/jdk12/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c:650:48: error: ‘%s’ directive output may be truncated writing up to 511 bytes into a region of size 507 [-Werror=format-truncation=]
(void)snprintf(buf, sizeof(buf), "JDWP %s", buf);
^~ ~~~
/home/stooke/dev/openjdk/jdk12/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c:650:15: note: ‘snprintf’ output between 6 and 517 bytes into a destination of size 512
(void)snprintf(buf, sizeof(buf), "JDWP %s", buf);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
gmake[3]: *** [Lib-jdk.jdwp.agent.gmk:54: /home/stooke/dev/openjdk/jdk12/build/linux-x86_64-server-release/support/native/jdk.jdwp.agent/libjdwp/debugInit.o] Error 1
gmake[2]: *** [make/Main.gmk:215: jdk.jdwp.agent-libs] Error 2
gmake[2]: *** Waiting for unfinished jobs....
^Cmake[1]: *** [/home/stooke/dev/openjdk/jdk12/make/Init.gmk:310: main] Interrupt
make: *** [/home/stooke/dev/openjdk/jdk12/make/Init.gmk:186: all] Interrupt
an input string.
src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c line 645:
(void)snprintf(buf, sizeof(buf), "JDWP %s", buf);
This was found by compiling with GCC 8.1
$ make all
Building target 'all' in configuration 'linux-x86_64-server-release'
Updating support/modules_libs/jdk.jdwp.agent/libjdwp.so due to 1 file(s)
/home/stooke/dev/openjdk/jdk12/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c: In function ‘jniFatalError’:
/home/stooke/dev/openjdk/jdk12/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c:650:24: error: passing argument 1 to restrict-qualified parameter aliases with argument 4 [-Werror=restrict]
(void)snprintf(buf, sizeof(buf), "JDWP %s", buf);
^~~ ~~~
/home/stooke/dev/openjdk/jdk12/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c: In function ‘jniFatalError.constprop’:
/home/stooke/dev/openjdk/jdk12/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c:650:48: error: ‘%s’ directive output may be truncated writing up to 511 bytes into a region of size 507 [-Werror=format-truncation=]
(void)snprintf(buf, sizeof(buf), "JDWP %s", buf);
^~ ~~~
/home/stooke/dev/openjdk/jdk12/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c:650:15: note: ‘snprintf’ output between 6 and 517 bytes into a destination of size 512
(void)snprintf(buf, sizeof(buf), "JDWP %s", buf);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
gmake[3]: *** [Lib-jdk.jdwp.agent.gmk:54: /home/stooke/dev/openjdk/jdk12/build/linux-x86_64-server-release/support/native/jdk.jdwp.agent/libjdwp/debugInit.o] Error 1
gmake[2]: *** [make/Main.gmk:215: jdk.jdwp.agent-libs] Error 2
gmake[2]: *** Waiting for unfinished jobs....
^Cmake[1]: *** [/home/stooke/dev/openjdk/jdk12/make/Init.gmk:310: main] Interrupt
make: *** [/home/stooke/dev/openjdk/jdk12/make/Init.gmk:186: all] Interrupt
Attachments
Issue Links
- backported by
-
JDK-8217003 Buffer written into itself
-
- Resolved
-
-
JDK-8219336 Buffer written into itself
-
- Resolved
-
-
JDK-8227214 Buffer written into itself
-
- Resolved
-
- relates to
-
JDK-8213153 Clean up GCC 8 errors
-
- Closed
-