]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
sunxi: Ensure that 'mksunxiboot' tool produces deterministic output
authorSiarhei Siamashka <siarhei.siamashka@gmail.com>
Wed, 2 Sep 2015 23:36:39 +0000 (02:36 +0300)
committerHans de Goede <hdegoede@redhat.com>
Thu, 10 Sep 2015 18:20:45 +0000 (20:20 +0200)
Currently some uninitialized padding bytes are written to the output
file, as can be confirmed with valgrind:

$ valgrind tools/mksunxiboot spl/u-boot-spl.bin spl/sunxi-spl.bin

==5581== Syscall param write(buf) points to uninitialised byte(s)
==5581==    at 0x4F0F940: __write_nocancel (in /lib64/libc-2.20.so)
==5581==    by 0x400839: main (in /tmp/u-boot/tools/mksunxiboot)
==5581==  Address 0xffeff5d3c is on thread 1's stack
==5581==  in frame #1, created by main (???)

This patch fixes the problem by clearing the whole structure instead
of just a portion of it.

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
tools/mksunxiboot.c

index 3361251c8e7fffcb4ccbc3e29eb5e2e956608b0c..676d392fb4d5a5c505fe505d4ab3d1ce25bc61eb 100644 (file)
@@ -99,7 +99,7 @@ int main(int argc, char *argv[])
                return EXIT_FAILURE;
        }
 
-       memset(img.pad, 0, BLOCK_SIZE);
+       memset(&img, 0, sizeof(img));
 
        /* get input file size */
        file_size = lseek(fd_in, 0, SEEK_END);