Skip to content

Commit 7bbd26b

Browse files
author
SendaoYan
committed
8362208: [8u] Buffer overflow in g1GCPhaseTimes.cpp::LineBuffer::_buffer
Reviewed-by: phh, stuefe
1 parent 26a41cd commit 7bbd26b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -34,13 +34,17 @@
3434
class LineBuffer: public StackObj {
3535

3636
private:
37-
static const int BUFFER_LEN = 1024;
37+
static const int BUFFER_LEN = 1024*3;
3838
static const int INDENT_CHARS = 3;
3939
char _buffer[BUFFER_LEN];
4040
int _indent_level;
4141
int _cur;
4242

4343
void vappend(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0) {
44+
if (_cur >= BUFFER_LEN) {
45+
DEBUG_ONLY(warning("previous LineBuffer overflow, request ignored");)
46+
return;
47+
}
4448
int res = os::vsnprintf(&_buffer[_cur], BUFFER_LEN - _cur, format, ap);
4549
if (res > BUFFER_LEN) {
4650
DEBUG_ONLY(warning("buffer too small in LineBuffer");)

0 commit comments

Comments
 (0)