JDK-8214061 : Buffer written into itself
  • Type: Bug
  • Component: core-svc
  • Sub-Component: debugger
  • Affected Version: 8,11,12
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-11-19
  • Updated: 2019-09-04
  • Resolved: 2018-12-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 12 Other
11.0.10-oracleFixed 12 b23Fixed openjdk8u212Fixed
Related Reports
Relates :  
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
Comments
I see the same pattern in current jdk8u-dev code, added "Affects Versions: 8".
08-02-2019

Moving from hotspot/svc -> core-svc/debugger. That's where libjdwp bugs live.
04-12-2018

Assigned to myself on behalf of Simon Tooke.
19-11-2018