]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
fix: df plugin: Fix an array out of bounds crash. 4252/head
authorFlorian Forster <octo@collectd.org>
Wed, 24 Jan 2024 14:08:14 +0000 (15:08 +0100)
committerFlorian Forster <octo@collectd.org>
Wed, 24 Jan 2024 14:08:14 +0000 (15:08 +0100)
The second argument of the `for` loop always evaluated to true, causing the
code to read past the end of the array.

ChangeLog: df plugin: An out of bounds read, causing segmentation faults, has been fixed.

src/df.c

index fb81a1bb8635be29f569893dc4105ce1a09efff0..bb12519d0d5bdf447e43f18faf6ed0f892a1f6c6 100644 (file)
--- a/src/df.c
+++ b/src/df.c
@@ -332,7 +332,7 @@ static int df_read(void) {
       &fam_inode_utilization,
   };
 
-  for (size_t i = 0; STATIC_ARRAY_SIZE(families); i++) {
+  for (size_t i = 0; i < STATIC_ARRAY_SIZE(families); i++) {
     if (families[i]->metric.num == 0) {
       continue;
     }