On Fri, Nov 6, 2020 at 2:01 PM David Holmes <david.hol...@oracle.com> wrote:
> On 6/11/2020 10:08 pm, Thomas Stuefe wrote: > > On Fri, 6 Nov 2020 12:02:28 GMT, Coleen Phillimore <cole...@openjdk.org> > wrote: > > > >>> src/jdk.jdwp.agent/share/native/libjdwp/log_messages.c line 84: > >>> > >>>> 82: // Truncate milliseconds in buffer large enough to hold the > >>>> 83: // value which is always < 1000 (and so a maximum of 3 digits > for "%.3s") > >>>> 84: char tmp[10 + 1]; > >>> > >>> I was wrong yesterday. Max len of %d would be 11 chars (if INT_MIN). > Can you make this buffer 11 chars please? > >>> > >>> (This error would have had no practical consequence: tmp[] would be > filled to the brim, leaving out the terminating zero, and since we then > print with %.3s, this would have had no negative effect. But its still > better to plan for \0 explicitly) > >> > >>> INT_MIN = "-2147483647" = 11 > >> If millisecs is unsigned do we not have to account for the minus sign? > >> > >> Why can't tmp just be 20 and we don't have to count characters since > snprintf will null terminate it? > > > > Sure, thats fine too! > > Don't we need the value to be smaller so that gcc "calculates" the total > to be within the size of the buffer? > > No, since we print it with "%.3s", so limited to 3 chars. ..Thomas > David > ----- > > > ------------- > > > > PR: https://git.openjdk.java.net/jdk/pull/1067 > > >