]> granicus.if.org Git - sysstat/commitdiff
Add sanity checks on values read from file
authorSebastien GODARD <sysstat@users.noreply.github.com>
Wed, 9 Mar 2022 15:53:27 +0000 (16:53 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Wed, 9 Mar 2022 15:53:27 +0000 (16:53 +0100)
Check upper bounds for @nr and @nr2 read from file to convert.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
sa_conv.c

index 08778e09452da84b032d475e7dc5d157d0730072..77f8e5e1b7a1393909f96461f6cfa59e568b0fad 100644 (file)
--- a/sa_conv.c
+++ b/sa_conv.c
@@ -318,7 +318,8 @@ int upgrade_header_section(char dfile[], int fd, int stdfd, struct activity *act
                        swap_struct(oact_types_nr, ofal, *arch_64);
                }
 
-               if ((ofal->nr < 1) || (ofal->nr2 < 1))
+               if ((ofal->nr < 1) || (ofal->nr2 < 1) ||
+                   (ofal->nr > NR_MAX) || (ofal->nr2 > NR2_MAX))
                        /*
                         * Every activity, known or unknown,
                         * should have at least one item and sub-item.
@@ -373,6 +374,7 @@ int upgrade_header_section(char dfile[], int fd, int stdfd, struct activity *act
                                act[p]->nr2    = ofal->nr2;
                        }
                }
+               /* else: Unknown activity. Maybe an old one which has been made obsolete? */
        }
 
        if (!a_cpu) {