]> www.infradead.org Git - mtd-utils.git/commitdiff
ubinize: validate number of sections
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Tue, 8 Jul 2008 11:06:35 +0000 (14:06 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Tue, 8 Jul 2008 12:29:04 +0000 (15:29 +0300)
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
ubi-utils/new-utils/src/ubinize.c

index af26d143ca2692852bf0448da2d44f1fa176fad9..f063b580a3c44e07716d5565a44d26a8a00f8982 100644 (file)
@@ -461,6 +461,14 @@ int main(int argc, char * const argv[])
                goto out_dict;
        }
 
+       if (sects > ui.max_volumes) {
+               errmsg("too many sections (%d) in the ini-file \"%s\"",
+                      sects, args.f_in);
+               normsg("each section corresponds to an UBI volume, maximum "
+                      "count of volumes is %d", ui.max_volumes);
+               goto out_dict;
+       }
+
        /*
         * Skip 2 PEBs at the beginning of the file for the volume table which
         * will be written later.
@@ -523,11 +531,11 @@ int main(int argc, char * const argv[])
                }
 
                /*
-                * Make sure the image size is not larger then the volume size.
+                * Make sure the image size is not larger than the volume size.
                 */
                if (st.st_size > vi.bytes) {
                        errmsg("error in section \"%s\": size of the image file \"%s\" "
-                              "is %lld, which is larger then the volume size %lld",
+                              "is %lld, which is larger than the volume size %lld",
                               sname, img, (long long)st.st_size, vi.bytes);
                        goto out_dict;
                }