Skip to content

Commit 3e041eb

Browse files
committed
8298248: Limit sscanf output width in cgroup file parsers
Reviewed-by: dholmes, sgehwolf
1 parent 4da8411 commit 3e041eb

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/hotspot/os/linux/cgroupV2Subsystem_linux.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ char * CgroupV2Subsystem::cpu_cpuset_cpus() {
9797

9898
char* CgroupV2Subsystem::cpu_quota_val() {
9999
GET_CONTAINER_INFO_CPTR(cptr, _unified, "/cpu.max",
100-
"Raw value for CPU quota is: %s", "%s %*d", quota, 1024);
100+
"Raw value for CPU quota is: %s", "%1023s %*d", quota, 1024);
101101
return os::strdup(quota);
102102
}
103103

@@ -141,7 +141,7 @@ jlong CgroupV2Subsystem::memory_max_usage_in_bytes() {
141141

142142
char* CgroupV2Subsystem::mem_soft_limit_val() {
143143
GET_CONTAINER_INFO_CPTR(cptr, _unified, "/memory.low",
144-
"Memory Soft Limit is: %s", "%s", mem_soft_limit_str, 1024);
144+
"Memory Soft Limit is: %s", "%1023s", mem_soft_limit_str, 1024);
145145
return os::strdup(mem_soft_limit_str);
146146
}
147147

@@ -163,14 +163,14 @@ jlong CgroupV2Subsystem::memory_and_swap_limit_in_bytes() {
163163

164164
char* CgroupV2Subsystem::mem_swp_limit_val() {
165165
GET_CONTAINER_INFO_CPTR(cptr, _unified, "/memory.swap.max",
166-
"Memory and Swap Limit is: %s", "%s", mem_swp_limit_str, 1024);
166+
"Memory and Swap Limit is: %s", "%1023s", mem_swp_limit_str, 1024);
167167
return os::strdup(mem_swp_limit_str);
168168
}
169169

170170
// memory.swap.current : total amount of swap currently used by the cgroup and its descendants
171171
char* CgroupV2Subsystem::mem_swp_current_val() {
172172
GET_CONTAINER_INFO_CPTR(cptr, _unified, "/memory.swap.current",
173-
"Swap currently used is: %s", "%s", mem_swp_current_str, 1024);
173+
"Swap currently used is: %s", "%1023s", mem_swp_current_str, 1024);
174174
return os::strdup(mem_swp_current_str);
175175
}
176176

@@ -197,7 +197,7 @@ jlong CgroupV2Subsystem::read_memory_limit_in_bytes() {
197197

198198
char* CgroupV2Subsystem::mem_limit_val() {
199199
GET_CONTAINER_INFO_CPTR(cptr, _unified, "/memory.max",
200-
"Raw value for memory limit is: %s", "%s", mem_limit_str, 1024);
200+
"Raw value for memory limit is: %s", "%1023s", mem_limit_str, 1024);
201201
return os::strdup(mem_limit_str);
202202
}
203203

@@ -223,7 +223,7 @@ char* CgroupV2Controller::construct_path(char* mount_path, char *cgroup_path) {
223223

224224
char* CgroupV2Subsystem::pids_max_val() {
225225
GET_CONTAINER_INFO_CPTR(cptr, _unified, "/pids.max",
226-
"Maximum number of tasks is: %s", "%s %*d", pidsmax, 1024);
226+
"Maximum number of tasks is: %s", "%1023s %*d", pidsmax, 1024);
227227
return os::strdup(pidsmax);
228228
}
229229

0 commit comments

Comments
 (0)