Some metric plugin functions read data from /proc/stat, and on systems with many cpus this file can exceed the size (30kB) of the buffer allocated to handle it. This isn't exactly a buffer overrun since the fread() is coded to not exceed the buffer size. What happens is, the read is truncated, and if the data we're looking for is in the truncated part it will cause a bug.
There are several functions affect, all in metricOperatingSystem.c. There are also functions that access this file in metricProcessor.c and metricUnixProcess.c but in one case the buffer is already big enough and in the other only the first line of the file is read, so these don't need to be touched.
I don't really like the idea of increasing the buffer size here (these functions could use a more efficient algorithm that doesn't require such a large buffer). But since it's stack space at least it won't accumulate, and will only increase the memory footprint during the data collection cycle.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Some metric plugin functions read data from /proc/stat, and on systems with many cpus this file can exceed the size (30kB) of the buffer allocated to handle it. This isn't exactly a buffer overrun since the fread() is coded to not exceed the buffer size. What happens is, the read is truncated, and if the data we're looking for is in the truncated part it will cause a bug.
There are several functions affect, all in metricOperatingSystem.c. There are also functions that access this file in metricProcessor.c and metricUnixProcess.c but in one case the buffer is already big enough and in the other only the first line of the file is read, so these don't need to be touched.
I don't really like the idea of increasing the buffer size here (these functions could use a more efficient algorithm that doesn't require such a large buffer). But since it's stack space at least it won't accumulate, and will only increase the memory footprint during the data collection cycle.
Patch attached.
Commit [62137d] for gather 2.2
Related
Commit: [62137d]