]> granicus.if.org Git - sysstat/commitdiff
Check value of variable "major" read from file
authorPeter Schiffer <pschiffe@redhat.com>
Tue, 5 May 2015 13:33:55 +0000 (15:33 +0200)
committerPeter Schiffer <pschiffe@redhat.com>
Tue, 5 May 2015 13:33:55 +0000 (15:33 +0200)
Variables "major" and "indirect" cannot be bigger than "MAX_BLKDEV" because they
are used as array index in "ioconf" and "ioc_refnr" arrays with size "MAX_BLKDEV
+ 1"

ioconf.c

index e2cb74bd9bdabb69d31fc70a1897d854f1306515..8f7fb25577cee102fe6fc7150dda78e47764783e 100644 (file)
--- a/ioconf.c
+++ b/ioconf.c
@@ -190,11 +190,16 @@ int ioc_init(void)
                                /* conventional usage for unsupported device */
                                continue;
                        }
-                       if (indirect >= MAX_BLKDEV) {
+                       if (indirect > MAX_BLKDEV) {
                                fprintf(stderr, "%s: Indirect major #%u out of range\n",
                                        ioconf_name, indirect);
                                continue;
                        }
+                       if (major > MAX_BLKDEV) {
+                               fprintf(stderr, "%s: Major #%u out of range\n",
+                                       ioconf_name, major);
+                               continue;
+                       }
                        if (ioconf[indirect] == NULL) {
                                fprintf(stderr,
                                        "%s: Indirect record '%u:%u:%u:...'"