From 6886152fb3af82376318c35eda416c3ce611121d Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Sun, 2 Dec 2018 17:45:58 +0100 Subject: [PATCH] Fix #202: Infinite loop in sadf 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 --- sa_common.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sa_common.c b/sa_common.c index fc3bea4..18fec02 100644 --- a/sa_common.c +++ b/sa_common.c @@ -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); -- 2.40.0