]> granicus.if.org Git - sysstat/commitdiff
sadc: Fix insecure data handling, really
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 25 Oct 2015 14:13:59 +0000 (15:13 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 25 Oct 2015 14:13:59 +0000 (15:13 +0100)
Commit 7ebfd7e checked upper bounds of values read from a possibly
tainted data file.
Add a lower bounds check to really fix the insecure data handling.
CID #29720.

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

diff --git a/sadc.c b/sadc.c
index d2e2cdfe83c5355a4e3c466934f4274b5cdf3e5a..160f9c57f294b711e8f55b017e0eb4653a0b5156 100644 (file)
--- a/sadc.c
+++ b/sadc.c
@@ -925,11 +925,11 @@ void open_ofile(int *ofd, char ofile[], int restart_mark)
                         */
                        goto append_error;
 
-               if (!file_act[i].nr || !file_act[i].nr2 ||
+               if ((file_act[i].nr <= 0) || (file_act[i].nr2 <= 0) ||
                    (file_act[i].nr > act[p]->nr_max) ||
                    (file_act[i].nr2 > NR2_MAX)) {
                        /*
-                        * Number of items and subitems should never be null,
+                        * Number of items and subitems should never be zero (or negative)
                         * or greater than their upper limit.
                         */
                        goto append_error;