]> granicus.if.org Git - sysstat/commitdiff
Fix #202: Infinite loop in sadf
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 2 Dec 2018 16:45:58 +0000 (17:45 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 2 Dec 2018 16:45:58 +0000 (17:45 +0100)
Check that structure's size is greater than 0 even for
unknown activities.
Else trying to skip this unknown activity in read_file_stat_bunch()
function will decrease offset pointer in file and result in an
infinite loop:

offset = (off_t) fal->size * (off_t) nr_value * (off_t) fal->nr2;

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

index fc3bea4b7539885a664240463b57d39e8ffa0ac8..18fec029bd469ff58d7cca700c07aa56db40e32a 100644 (file)
@@ -1920,7 +1920,7 @@ void check_file_actlst(int *ifd, char *dfile, struct activity *act[],
 
                /*
                 * Every activity, known or unknown, should have
-                * at least one item and sub-item.
+                * at least one item and sub-item, and a positive size value.
                 * Also check that the number of items and sub-items
                 * doesn't exceed a max value. This is necessary
                 * because we will use @nr and @nr2 to
@@ -1930,7 +1930,8 @@ void check_file_actlst(int *ifd, char *dfile, struct activity *act[],
                 * activities which have each a specific max value.
                 */
                if ((fal->nr < 1) || (fal->nr2 < 1) ||
-                   (fal->nr > NR_MAX) || (fal->nr2 > NR2_MAX)) {
+                   (fal->nr > NR_MAX) || (fal->nr2 > NR2_MAX) ||
+                   (fal->size <= 0)) {
 #ifdef DEBUG
                        fprintf(stderr, "%s: id=%d nr=%d nr2=%d\n",
                                __FUNCTION__, fal->id, fal->nr, fal->nr2);