Discussion:
RFR: (XS) 8214061: Buffer written into itself
(too old to reply)
Simon Tooke
2018-12-04 14:57:41 UTC
Permalink
In one fatal error code path, snprintf() is given its output buffer asan
input string. 

src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c line 645: 

    (void)snprintf(buf, sizeof(buf), "JDWP %s", buf);

Proposed fix is of course:

    (void)snprintf(buf, sizeof(buf), "JDWP %s", msg);

This was found by compiling with GCC 8.1

Bug: https://bugs.openjdk.java.net/browse/JDK-8214061
webrev: http://cr.openjdk.java.net/~sgehwolf/webrevs/stooke/JDK-8214061/01/webrev/


Thanks,
-Simon Tooke
Daniel D. Daugherty
2018-12-04 15:08:54 UTC
Permalink
Post by Simon Tooke
In one fatal error code path, snprintf() is given its output buffer asan
input string.
    (void)snprintf(buf, sizeof(buf), "JDWP %s", buf);
    (void)snprintf(buf, sizeof(buf), "JDWP %s", msg);
This was found by compiling with GCC 8.1
Bug: https://bugs.openjdk.java.net/browse/JDK-8214061
webrev: http://cr.openjdk.java.net/~sgehwolf/webrevs/stooke/JDK-8214061/01/webrev/
src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c
    No comments.

Thumbs up.

Dan
Post by Simon Tooke
Thanks,
-Simon Tooke
Severin Gehwolf
2018-12-04 16:02:49 UTC
Permalink
Hi,
Post by Simon Tooke
Post by Simon Tooke
In one fatal error code path, snprintf() is given its output buffer asan
input string.
(void)snprintf(buf, sizeof(buf), "JDWP %s", buf);
(void)snprintf(buf, sizeof(buf), "JDWP %s", msg);
This was found by compiling with GCC 8.1
Bug: https://bugs.openjdk.java.net/browse/JDK-8214061
webrev: http://cr.openjdk.java.net/~sgehwolf/webrevs/stooke/JDK-8214061/01/webrev/
src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c
No comments.
Thumbs up.
Can this be considered trivial enough to only require one reviewer?

FWIW, this looks good to me too, but I'm not a Reviewer.

Thanks,
Severin
Daniel D. Daugherty
2018-12-04 16:42:56 UTC
Permalink
Post by Severin Gehwolf
Hi,
Post by Simon Tooke
Post by Simon Tooke
In one fatal error code path, snprintf() is given its output buffer asan
input string.
(void)snprintf(buf, sizeof(buf), "JDWP %s", buf);
(void)snprintf(buf, sizeof(buf), "JDWP %s", msg);
This was found by compiling with GCC 8.1
Bug: https://bugs.openjdk.java.net/browse/JDK-8214061
webrev: http://cr.openjdk.java.net/~sgehwolf/webrevs/stooke/JDK-8214061/01/webrev/
src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c
No comments.
Thumbs up.
Can this be considered trivial enough to only require one reviewer?
Yes. This is trivial so only one (R)eviewer is needed.
Post by Severin Gehwolf
FWIW, this looks good to me too, but I'm not a Reviewer.
That's okay. You can still be listed as a (r)eviewer. So now it
has 2 folks... :-)

Dan
Post by Severin Gehwolf
Thanks,
Severin
Severin Gehwolf
2018-12-04 16:56:18 UTC
Permalink
Post by Daniel D. Daugherty
Post by Severin Gehwolf
Hi,
Post by Simon Tooke
Post by Simon Tooke
In one fatal error code path, snprintf() is given its output buffer asan
input string.
(void)snprintf(buf, sizeof(buf), "JDWP %s", buf);
(void)snprintf(buf, sizeof(buf), "JDWP %s", msg);
This was found by compiling with GCC 8.1
Bug: https://bugs.openjdk.java.net/browse/JDK-8214061
webrev: http://cr.openjdk.java.net/~sgehwolf/webrevs/stooke/JDK-8214061/01/webrev/
src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c
No comments.
Thumbs up.
Can this be considered trivial enough to only require one reviewer?
Yes. This is trivial so only one (R)eviewer is needed.
Post by Severin Gehwolf
FWIW, this looks good to me too, but I'm not a Reviewer.
That's okay. You can still be listed as a (r)eviewer. So now it
has 2 folks... :-)
OK. Thanks, Dan.

Cheers,
Severin
s***@oracle.com
2018-12-04 16:56:32 UTC
Permalink
Hi Simon,

Nice catch!
Looks good.
Copyright comment needs an update.

Thanks,
Serguei
Post by Daniel D. Daugherty
Post by Severin Gehwolf
Hi,
Post by Simon Tooke
Post by Simon Tooke
In one fatal error code path, snprintf() is given its output buffer asan
input string.
      (void)snprintf(buf, sizeof(buf), "JDWP %s", buf);
      (void)snprintf(buf, sizeof(buf), "JDWP %s", msg);
This was found by compiling with GCC 8.1
Bug: https://bugs.openjdk.java.net/browse/JDK-8214061
http://cr.openjdk.java.net/~sgehwolf/webrevs/stooke/JDK-8214061/01/webrev/
src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c
      No comments.
Thumbs up.
Can this be considered trivial enough to only require one reviewer?
Yes. This is trivial so only one (R)eviewer is needed.
Post by Severin Gehwolf
FWIW, this looks good to me too, but I'm not a Reviewer.
That's okay. You can still be listed as a (r)eviewer. So now it
has 2 folks... :-)
Dan
Post by Severin Gehwolf
Thanks,
Severin
Loading...