]> granicus.if.org Git - sysstat/commitdiff
Fix untrusted value used as argument
authorSebastien GODARD <sysstat@users.noreply.github.com>
Tue, 6 Oct 2015 14:58:01 +0000 (16:58 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Tue, 6 Oct 2015 14:58:01 +0000 (16:58 +0200)
sa_vol_act_nr is read from an untrusted source and used as a loop
boundary. Check it before using it.
CID #29720.

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

diff --git a/sadc.c b/sadc.c
index 31fa9ed6f3630c32014108e33e8fac088c45e91a..da4c9fb5a8c348d60b1d51c8d0176c3824348477 100644 (file)
--- a/sadc.c
+++ b/sadc.c
@@ -896,9 +896,11 @@ void open_ofile(int *ofd, char ofile[], int restart_mark)
        }
 
        /* OK: It's a true system activity file */
-       if (!file_hdr.sa_act_nr || (file_hdr.sa_act_nr > NR_ACT))
+       if (!file_hdr.sa_act_nr || (file_hdr.sa_act_nr > NR_ACT) ||
+           (file_hdr.sa_vol_act_nr > NR_ACT))
                /*
-                * No activities at all or at least one unknown activity:
+                * No activities at all or at least one unknown activity,
+                * or too many volatile activities:
                 * Cannot append data to such a file.
                 */
                goto append_error;