Skip to contentSkip to conversation

sunxi: Ensure that 'mksunxiboot' tool produces deterministic output

PATCH New Siarhei Siamashka 2 participants 2 messages Sep 2, 2015 – Sep 10, 2015 Arm/Allwinner sunXi SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sunxi: Ensure that 'mksunxiboot' tool produces deterministic output

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.

---
 tools/mksunxiboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/mksunxiboot.c +1 -1
index 3361251..676d392 100644
@@ -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);
Signature · 1 line
2.4.6
#1 lore raw

PATCH 1/1 sunxi: Ensure that 'mksunxiboot' tool produces deterministic output

Hi,

Quoted 11 lines · Siarhei Siamashka

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 (???)

Quoted 4 lines

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

Thanks, I've queued this one up for the next pull-req.

Regards,

Hans

Quoted 18 lines
---
  tools/mksunxiboot.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/mksunxiboot.c +1 -1
index 3361251..676d392 100644
@@ -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);