]> www.infradead.org Git - mtd-utils.git/commitdiff
ubinize: correct subpage_size print and initialise vol_info to zero
authorAdrian Hunter <ext-adrian.hunter@nokia.com>
Mon, 3 Nov 2008 08:41:58 +0000 (10:41 +0200)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Thu, 6 Nov 2008 08:49:24 +0000 (10:49 +0200)
J. Scott Merritt wrote:
> Dear list,
>
> I believe that I have stumbled upon two problems with the latest version
> of ubinize.c in mtd-utils - one serious, and one not so serious.
>
> - First, the easy one: At line 457, I believe that we should be printing
> args.subpage_size rather than ui.min_io_size.
>
> - More seriously, I believe that the "flags" field in the ubigen_vol_info
> structures is not being properly initialized.  Line 494 allocates memory
> for these structures with malloc, so they are not cleared to zero.  The
> read_section function updates the flag field if the AUTO-RESIZE flag is
> specified, but does not otherwise initialize or clear it.
>
> I reckon the latter problem could be repaired either with calloc, or by
> modifying read_section to more directly set/clear the flag.
>
> Thanks, Scott.

Reported-by: J. Scott Merritt <merrij3@rpi.edu>
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
ubi-utils/new-utils/src/ubinize.c

index ebd5aa041432514337b48651ed8261f2def110e3..4f3e8a194daa60416b71cdcc7c8f408d0a5e59db 100644 (file)
@@ -454,7 +454,7 @@ int main(int argc, char * const argv[])
        verbose(args.verbose, "LEB size:      %d", ui.leb_size);
        verbose(args.verbose, "PEB size:      %d", ui.peb_size);
        verbose(args.verbose, "min. I/O size: %d", ui.min_io_size);
-       verbose(args.verbose, "sub-page size: %d", ui.min_io_size);
+       verbose(args.verbose, "sub-page size: %d", args.subpage_size);
        verbose(args.verbose, "VID offset:    %d", ui.vid_hdr_offs);
        verbose(args.verbose, "data offset:   %d", ui.data_offs);
 
@@ -491,7 +491,7 @@ int main(int argc, char * const argv[])
                goto out_dict;
        }
 
-       vi = malloc(sizeof(struct ubigen_vol_info) * sects);
+       vi = calloc(sizeof(struct ubigen_vol_info), sects);
        if (!vi) {
                errmsg("cannot allocate memory");
                goto out_dict;