8362208: [8u] Buffer overflow in g1GCPhaseTimes.cpp::LineBuffer::_buffer

Reviewed-by: phh, stuefe
This commit is contained in:
SendaoYan 2025-09-26 09:32:07 +00:00
parent 26a41cde17
commit 7bbd26b326

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -34,13 +34,17 @@
class LineBuffer: public StackObj {
private:
static const int BUFFER_LEN = 1024;
static const int BUFFER_LEN = 1024*3;
static const int INDENT_CHARS = 3;
char _buffer[BUFFER_LEN];
int _indent_level;
int _cur;
void vappend(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0) {
if (_cur >= BUFFER_LEN) {
DEBUG_ONLY(warning("previous LineBuffer overflow, request ignored");)
return;
}
int res = os::vsnprintf(&_buffer[_cur], BUFFER_LEN - _cur, format, ap);
if (res > BUFFER_LEN) {
DEBUG_ONLY(warning("buffer too small in LineBuffer");)