RE: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-15 Thread Langer, Christoph
t; Cc: serviceability-dev@openjdk.java.net; Hotspot dev runtime runtime-...@openjdk.java.net>; David Holmes > ; Thomas Stüfe > Subject: RE: RFR (XS): 8199010: attachListener.hpp: Fix potential null > termination issue found by coverity scans > > Hi, > > here is the final webrev f

RE: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-12 Thread Langer, Christoph
Stüfe > Subject: Re: RFR (XS): 8199010: attachListener.hpp: Fix potential null > termination issue found by coverity scans > > On 3/9/18 4:50 AM, Langer, Christoph wrote: > > Hi Chris, > > > >>> Secondly, it doesn't accept the assert as length check

Re: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-09 Thread Chris Plummer
On 3/9/18 4:50 AM, Langer, Christoph wrote: Hi Chris, Secondly, it doesn't accept the assert as length check and complains: fixed_size_dest: You might overrun the 17-character fixed-size string this- _name by copying name without checking the length. Agreed that the assert is not a length chec

RE: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-09 Thread Langer, Christoph
Hi Chris, > > Secondly, it doesn't accept the assert as length check and complains: > > fixed_size_dest: You might overrun the 17-character fixed-size string this- > >_name by copying name without checking the length. > Agreed that the assert is not a length check in product builds. However, > the

Re: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-08 Thread Chris Plummer
Hi Christoph, On 3/8/18 3:38 AM, Langer, Christoph wrote: Hi Chris, I went back to the original code in coverity and checked what it complains about. This is the original code: assert(strlen(name) <= name_length_max, "exceeds maximum name length"); strcpy(_name, name); Coverity h

RE: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-08 Thread Langer, Christoph
Hi Chris, I went back to the original code in coverity and checked what it complains about. This is the original code: assert(strlen(name) <= name_length_max, "exceeds maximum name length"); strcpy(_name, name); Coverity has various issues with this. First, it generally considers str

Re: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-06 Thread Thomas Stüfe
Maybe stupid question, any reason we could not just strdup() those strings? And add an ~AttachOperation dtor to clean them up again? Otherwise, I usually prefer using snprintf (or, jio_snprintf or the new os::snprintf()) with "%s" as format string: jio_snprintf(_name, sizeof(_name), "%s", inputst

RE: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-06 Thread Langer, Christoph
Hi Chris, > > I don't know why strncpy would do zero padding? > From the man page: > > The stpncpy() and strncpy() functions copy at most len characters > from src into dst.  If src is less than len > characters long, the remainder of dst is filled with `\0' > characters.  Otherwise,

Re: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-06 Thread Chris Plummer
On 3/6/18 4:26 AM, David Holmes wrote: On 6/03/2018 6:50 PM, Langer, Christoph wrote: Hi Chris, David and Thomas, I took a closer look now, too. Funny that the original change was contributed by my colleagues because of coverity and that they didn't do it completely right. 😉 As a code comment

RE: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-06 Thread Langer, Christoph
13:26 > To: Langer, Christoph ; Chris Plummer > ; Thomas Stüfe > Cc: serviceability-dev@openjdk.java.net; Hotspot dev runtime runtime-...@openjdk.java.net> > Subject: Re: RFR (XS): 8199010: attachListener.hpp: Fix potential null > termination issue found by coverity scans > &

Re: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-06 Thread David Holmes
On 6/03/2018 6:50 PM, Langer, Christoph wrote: Hi Chris, David and Thomas, I took a closer look now, too. Funny that the original change was contributed by my colleagues because of coverity and that they didn't do it completely right. 😉 As a code comment in our attachListener.hpp suggests, the

RE: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-06 Thread Langer, Christoph
Hi Chris, David and Thomas, I took a closer look now, too. Funny that the original change was contributed by my colleagues because of coverity and that they didn't do it completely right. 😉 As a code comment in our attachListener.hpp suggests, the '0' termination to please coverity was added fa

Re: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-05 Thread Chris Plummer
On 3/5/18 3:31 PM, David Holmes wrote: On 6/03/2018 8:37 AM, Chris Plummer wrote: On 3/5/18 1:28 PM, Langer, Christoph wrote: Hi Chris, Asserts imply something that is suppose to never happen, but that you want to check for in debug builds to help uncover bugs. Given this, either we have a bu

Re: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-05 Thread David Holmes
On 6/03/2018 8:37 AM, Chris Plummer wrote: On 3/5/18 1:28 PM, Langer, Christoph wrote: Hi Chris, Asserts imply something that is suppose to never happen, but that you want to check for in debug builds to help uncover bugs. Given this, either we have a bug (and someone can pass in a name that i

Re: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-05 Thread Chris Plummer
On 3/5/18 1:28 PM, Langer, Christoph wrote: Hi Chris, Asserts imply something that is suppose to never happen, but that you want to check for in debug builds to help uncover bugs. Given this, either we have a bug (and someone can pass in a name that is too long), or coverity is complaining abou

Re: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-05 Thread David Holmes
r it reviewed from your end? I’m trying the submission repo right now with this change… Best regards Christoph From: Thomas Stüfe [mailto:thomas.stu...@gmail.com] Sent: Montag, 5. März 2018 15:53 To: Langer, Christoph Cc: Hotspot dev runtime ; serviceability-dev@openjdk.java.net Subject:

RE: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-05 Thread Langer, Christoph
Hi Chris, > Asserts imply something that is suppose to never happen, but that you > want to check for in debug builds to help uncover bugs. Given this, > either we have a bug (and someone can pass in a name that is too long), > or coverity is complaining about something that can never happen, or t

Re: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-05 Thread Chris Plummer
submission repo right now with this change… Best regards Christoph From: Thomas Stüfe [mailto:thomas.stu...@gmail.com] Sent: Montag, 5. März 2018 15:53 To: Langer, Christoph Cc: Hotspot dev runtime ; serviceability-dev@openjdk.java.net Subject: Re: RFR (XS): 8199010: attachListener.hpp: Fix potential

Re: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-05 Thread Chris Plummer
runtime ; serviceability-dev@openjdk.java.net Subject: Re: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans Hi Christoph, Seeing that truncation is considered assertion worthy, should we really hide it in release? Gruß Thomas On Mar 5, 2018 10

RE: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-05 Thread Langer, Christoph
right now with this change… Best regards Christoph From: Thomas Stüfe [mailto:thomas.stu...@gmail.com] Sent: Montag, 5. März 2018 15:53 To: Langer, Christoph Cc: Hotspot dev runtime ; serviceability-dev@openjdk.java.net Subject: Re: RFR (XS): 8199010: attachListener.hpp: Fix potential null

Re: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-05 Thread Thomas Stüfe
Hi Christoph, Seeing that truncation is considered assertion worthy, should we really hide it in release? Gruß Thomas On Mar 5, 2018 10:03, "Langer, Christoph" wrote: > Hi, > > please review a small fix that was identified by a coverity code scan. > > In case strlen(name) was the same or large

Re: RFR (XS): 8199010: attachListener.hpp: Fix potential null termination issue found by coverity scans

2018-03-05 Thread David Holmes
Hi Christoph, On 5/03/2018 7:03 PM, Langer, Christoph wrote: Hi, please review a small fix that was identified by a coverity code scan. In case strlen(name) was the same or larger than name_length_max or resp. strlen(arg) >= arg_length_max, the _name or _arg fields would not get null termina