On Fri, 6 Nov 2020 13:28:12 GMT, Coleen Phillimore <cole...@openjdk.org> wrote:

>> Apply patch suggested by @cl4es in the bug report.  Passes 
>> linux-x86-open,linux-x64-open,linux-s390x-open,linux-arm32-debug,linux-ppc64le-debug
>>  builds with this patch, and tier1.
>> 
>> thanks,
>> Coleen
>
> Coleen Phillimore has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   More.

src/jdk.jdwp.agent/share/native/libjdwp/log_messages.c line 86:

> 84:     char tmp[20];
> 85:     snprintf(tmp, sizeof(tmp), "%.3d", millisecs);
> 86:     snprintf(tbuf, ltbuf, "%s.%s %s", timestamp_date_time, tmp, 
> timestamp_timezone);

Sorry, Coleen, we still miss the precision limit in the second printf.

char tmp[20];
snprintf(tmp, sizeof(tmp), "%.3d", millisecs);
snprintf(tbuf, ltbuf, "%s.%.3s %s", timestamp_date_time, tmp, 
timestamp_timezone);
                          ^^^^

The point was to first print the digit with enough space to hold its 
stringified value (20 is more than enough). We need to print that one with .3d 
to get zero-padding to three digits if the value is <100.

Then to print that stringified version with ".3s" since, in contrast to %d, 
with %s the precision actually works as a limiter.

Thanks for your patience.

-------------

PR: https://git.openjdk.java.net/jdk/pull/1067

Reply via email to