aboutsummaryrefslogtreecommitdiffstats
path: root/erts/lib_src/common
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2012-03-15 16:42:40 +0100
committerSverker Eriksson <[email protected]>2012-03-15 16:45:13 +0100
commit8c34a2dc70070cca8d97ad3c0f2dfbec1a0d82d8 (patch)
tree46e61086f0a9e8d47614da1abb447c85ab8b69f0 /erts/lib_src/common
parent7484721f847e95380e66456b4a55e08481b570d8 (diff)
downloadotp-8c34a2dc70070cca8d97ad3c0f2dfbec1a0d82d8.tar.gz
otp-8c34a2dc70070cca8d97ad3c0f2dfbec1a0d82d8.tar.bz2
otp-8c34a2dc70070cca8d97ad3c0f2dfbec1a0d82d8.zip
erts: Fix memory corruption when reading topology info
If the number of processors actually found while reading sysfs is lower than the configured value, we realloc() the cpuinfo array to the smaller size, but we then iterate it using the original configured size, thus corrupting memory beyond the allocated block.
Diffstat (limited to 'erts/lib_src/common')
-rw-r--r--erts/lib_src/common/erl_misc_utils.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/erts/lib_src/common/erl_misc_utils.c b/erts/lib_src/common/erl_misc_utils.c
index 4806311dfe..162c908285 100644
--- a/erts/lib_src/common/erl_misc_utils.c
+++ b/erts/lib_src/common/erl_misc_utils.c
@@ -727,7 +727,7 @@ adjust_processor_nodes(erts_cpu_info_t *cpuinfo, int no_nodes)
prev = NULL;
this = &cpuinfo->topology[0];
- last = &cpuinfo->topology[cpuinfo->configured-1];
+ last = &cpuinfo->topology[cpuinfo->topology_size-1];
while (1) {
if (processor == this->processor) {
if (node != this->node)
@@ -939,7 +939,7 @@ read_topology(erts_cpu_info_t *cpuinfo)
if (res > 1) {
prev = this++;
- last = &cpuinfo->topology[cpuinfo->configured-1];
+ last = &cpuinfo->topology[cpuinfo->topology_size-1];
while (1) {
this->thread = ((this->node == prev->node
@@ -1094,7 +1094,7 @@ read_topology(erts_cpu_info_t *cpuinfo)
if (res > 1) {
prev = this++;
- last = &cpuinfo->topology[cpuinfo->configured-1];
+ last = &cpuinfo->topology[cpuinfo->topology_size-1];
while (1) {
this->thread = ((this->node == prev->node