u-boot-brain/tools
Philipp Tomsich c8e1ca3ebf tools: omapimage: fix corner-case in byteswap path
Since commit 2614a20847 ("common: command: tempory buffer should
have size of command line buf"), there have been consistent Travis CI
failures on my builds (interestingly not for Tom, even though building
the same commit id) due to a SEGV in building the byteswapped
omapimage:
     	    arm: pcm051_rev3
     make[2]: *** [MLO.byteswap] Error 139
     	      	  		       ^^^ error code for a SEGV

Turns out that the word-based byte-swapping loop in omapimage.c is to
blame. With the loop condition
       while (swapped <= (sbuf->st_size / sizeof(uint32_t)))
there had been one-too-many iterations for all file sizes divisible by
the sizeof(uint32_t).  I.e. we had 1 iteration for 0 bytes (and also 1
through 3 bytes) and 2 iterations at 4 bytes... clearly overshooting
on 0 and 4 bytes.

This commit fixes the calculation of an up-rounded word-count and
makes sure to keep the zero-based loop-counter below the number of
words to be processed.

References: 2614a20 ("common: command: tempory buffer should have size of command line buf")
Fixes: 79b9ebb ("omapimage: Add support for byteswapped SPI images")
Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Reviewed-by: Martin Elshuber <martin.elshuber@theobroma-systems.com>
2017-12-05 21:56:29 -05:00
..
binman binman: Return non-zero exit code on test failure 2017-11-22 18:05:38 -07:00
buildman buildman: Fix up tests 2017-11-22 18:05:38 -07:00
dtoc dtoc: Fix up tests 2017-11-22 18:05:38 -07:00
easylogo Various Makefiles: Add SPDX-License-Identifier tags 2015-11-10 09:19:52 -05:00
env tools: env: Add support for direct read/write UBI volumes 2017-11-29 22:30:50 -05:00
gdb Makefile: move BFD_ROOT_DIR to tools/gdb/Makefile 2014-02-19 11:07:50 -05:00
kermit tools: move kermit files to tools/kermit directory 2014-01-24 16:59:07 -05:00
libfdt libfdt: migrate fdt_wip.c to a wrapper of scripts/dtc/libfdt/fdt_wip.c 2017-12-04 09:59:02 -05:00
logos lib: at91: Add logo files used via API of DM_VIDEO 2017-09-14 16:02:43 -04:00
omap Add GPL-2.0+ SPDX-License-Identifier to source files 2013-07-24 09:44:38 -04:00
patman patman: Fix up tests to pass with newest checkpatch 2017-11-22 18:05:38 -07:00
scripts tools: fix define2mk.sed to not add quotes around negative integers 2016-06-13 07:46:29 +09:00
.gitignore pylibfdt: move pylibfdt to scripts/dtc/pylibfdt and refactor makefile 2017-11-17 07:43:32 -05:00
aisimage.c imagetool: replace image registration function by linker_lists feature 2015-01-29 13:38:41 -05:00
aisimage.h Coding Style cleanup: remove trailing white space 2013-10-14 16:06:53 -04:00
atmel_pmecc_params.c Change my mailaddress 2016-05-02 18:37:09 -04:00
atmelimage.c Change my mailaddress 2016-05-02 18:37:09 -04:00
bmp_logo.c tools: bmp_logo: correctly interpret BMP files with larger headers 2017-10-16 09:42:51 -04:00
default_image.c tools: mkimage: add firmware-ivt image type for HAB verification 2017-01-02 17:06:57 +01:00
dumpimage.c dumpimage: replace the term "datafile" by "subimage" 2015-01-29 13:38:41 -05:00
dumpimage.h includes: move openssl headers to include/u-boot 2014-06-19 11:19:04 -04:00
envcrc.c tools/env: Correct include kconfig 2016-11-23 23:41:23 -08:00
fdt_host.h tools, fit_check_sign: verify a signed fit image 2014-03-21 16:40:38 -04:00
fdtgrep.c Do not attempt to use the systemwide libfdt 2017-11-06 09:59:02 -05:00
fit_check_sign.c Fix bad return value checks (detected with Coccinelle) 2015-10-24 13:50:30 -04:00
fit_common.c mkimage: Automatically make space in FDT when full 2014-06-11 16:25:46 -04:00
fit_common.h mkimage: Automatically make space in FDT when full 2014-06-11 16:25:46 -04:00
fit_image.c tools/mkimage: Fix DTC run command to handle file names with space 2017-10-16 09:42:51 -04:00
fit_info.c tools, fit_info: increase buffer for command name 2014-08-14 11:20:24 +02:00
gen_eth_addr.c tools: gen_eth_addr: add getpid() to time(0) to avoid duplicated seed 2015-09-28 10:48:25 -04:00
gen_ethaddr_crc.c tools: Add tool to add crc8 to a mac address 2017-02-07 10:54:33 -06:00
genboardscfg.py genconfig.py: Print defconfig next to warnings 2017-09-11 21:43:58 -06:00
getline.c Add GPL-2.0+ SPDX-License-Identifier to source files 2013-07-24 09:44:38 -04:00
getline.h getline: split out for darwin systems 2010-01-26 00:07:13 +01:00
gpheader.h tools: mkimage: add support for gpimage format 2014-04-17 17:24:38 -04:00
gpimage-common.c dumpimage: add 'T' option to explicitly set the image type 2015-01-29 13:38:41 -05:00
gpimage.c imagetool: replace image registration function by linker_lists feature 2015-01-29 13:38:41 -05:00
ifdtool.c binman: Drop microcode features from ifdtool 2016-12-20 08:09:55 +13:00
ifdtool.h tools/ifdtool: Support writing multiple files (-w) simultaneously 2014-12-13 22:32:04 -07:00
image-host.c tools: image: fix message when fail to add verification data for config 2017-11-06 09:59:01 -05:00
imagetool.c Respect SOURCE_DATE_EPOCH when building FIT images. 2016-06-24 17:23:10 -04:00
imagetool.h mkimage: Add support for signing with pkcs11 2017-01-14 16:47:13 -05:00
img2brec.sh Coding Style cleanup: replace leading SPACEs by TABs 2013-10-14 16:06:54 -04:00
img2srec.c treewide: remove unneeded semicolons 2017-06-16 10:11:38 -04:00
imximage.c tools: imximage: add set bit command 2017-03-19 17:30:15 +01:00
jtagconsole Blackfin: jtagconsole: disable output processing 2010-07-25 15:17:23 -04:00
kwbimage.c tools/kwbimage: fix v1 header verification 2017-07-12 06:57:55 +02:00
kwbimage.h tools/kwbimage.h: make offset marks style consistent 2017-07-12 06:57:55 +02:00
kwboot.c tools: kwboot: don't adjust destaddr when patching the image 2017-02-17 10:15:56 +01:00
lpc32xximage.c lpc32xx: add lpc32xx-spl.bin boot image target 2015-04-10 14:23:26 +02:00
Makefile libfdt: migrate fdt_wip.c to a wrapper of scripts/dtc/libfdt/fdt_wip.c 2017-12-04 09:59:02 -05:00
microcode-tool x86: Add a script to process Intel microcode files 2014-12-18 17:26:08 -07:00
microcode-tool.py tools: microcode-tool: Support parsing header file with a license block 2016-01-13 12:20:14 +08:00
mingw_support.c Add LGPL-2.0+ SPDX-License-Identifier to source files 2013-07-24 09:45:01 -04:00
mingw_support.h Add LGPL-2.0+ SPDX-License-Identifier to source files 2013-07-24 09:45:01 -04:00
mips-relocs.c mips-relocs: Fix warning from gcc 6.3 2017-07-25 20:44:38 +02:00
mkenvimage.c Patch to mkenvimage to handle text files with length that exceed env size 2015-03-28 12:07:47 -04:00
mkexynosspl.c Fix bad return value checks (detected with Coccinelle) 2015-10-24 13:50:30 -04:00
mkimage.c mkimage: fix display of image types list 2017-07-06 16:17:16 -04:00
mkimage.h dtc: mkimage: Add the possibility to specify DTC 2017-07-22 15:36:19 -04:00
mksunxiboot.c sunxi: Store the device tree name in the SPL header 2017-05-17 23:23:58 +05:30
moveconfig.py moveconfig: fix error message in do_autoconf() 2017-10-15 18:13:13 +09:00
mxsboot.c mxsboot: remove unused include 2016-02-21 11:09:19 +01:00
mxsimage.c tools: mxsimage: Fix build with OpenSSL 1.1.x 2016-12-19 12:26:39 -05:00
mxsimage.h ARM: mxs: tools: Add support for boot progress display flag 2014-11-20 10:13:45 +01:00
ncb.c ncb: Check return value of write() 2009-04-28 01:16:46 +02:00
netconsole net: Make netconsole src and dest ports configurable 2012-09-24 13:17:24 -05:00
omapimage.c tools: omapimage: fix corner-case in byteswap path 2017-12-05 21:56:29 -05:00
omapimage.h tools: mkimage: add support for gpimage format 2014-04-17 17:24:38 -04:00
os_support.c Add LGPL-2.0+ SPDX-License-Identifier to source files 2013-07-24 09:45:01 -04:00
os_support.h Add LGPL-2.0+ SPDX-License-Identifier to source files 2013-07-24 09:45:01 -04:00
pbl_crc32.c mkimage : Split out and clean pbl_crc32 for use by other image types 2014-06-05 14:38:38 -04:00
pbl_crc32.h mkimage : Split out and clean pbl_crc32 for use by other image types 2014-06-05 14:38:38 -04:00
pblimage.c tools: pblimage: Fix address calculation 2017-09-11 07:55:36 -07:00
pblimage.h Coding Style cleanup: remove trailing white space 2013-10-14 16:06:53 -04:00
proftool.c tools/proftool: fix use-after-free 2015-11-16 17:22:18 -05:00
relocate-rela.c relocate-rela: add missing va_end() 2017-05-05 16:45:57 -04:00
rkcommon.c rockchip: mkimage: remove unused code-paths (spl_boot0 is now implied) 2017-11-21 23:57:23 +01:00
rkcommon.h rockchip: mkimage: force 2KB alignment for init_size 2017-06-07 07:29:22 -06:00
rkimage.c rockchip: mkimage: remove placeholder functions from rkimage 2017-05-10 13:37:21 -06:00
rkmux.py rockchip: Add a script to parse datasheets 2016-01-21 20:42:37 -07:00
rksd.c rockchip: mkimage: force 2KB alignment for init_size 2017-06-07 07:29:22 -06:00
rkspi.c rockchip: mkimage: force 2KB alignment for init_size 2017-06-07 07:29:22 -06:00
socfpgaimage.c tools: do not print error messages in verify_header() functions 2015-01-29 13:38:41 -05:00
sunxi-spl-image-builder.c tools: sunxi: avoid read after end of string 2017-05-05 16:45:57 -04:00
ublimage.c imagetool: replace image registration function by linker_lists feature 2015-01-29 13:38:41 -05:00
ublimage.h Coding Style cleanup: remove trailing white space 2013-10-14 16:06:53 -04:00
ubsha1.c includes: move openssl headers to include/u-boot 2014-06-19 11:19:04 -04:00
vybridimage.c tools: mkimage: add support for Vybrid image format 2016-10-06 09:06:16 +02:00
xway-swap-bytes.c MIPS: INCA-IP: rename inca-swap-bytes host tool 2011-07-31 23:25:41 +09:00
zynqimage.c tools: mkimage: Call fclose in error path 2016-12-27 11:24:16 -05:00
zynqmpimage.c tools: zynqmpimage: adjust ug1085 reference to v1.4 of the document 2017-11-29 08:02:40 +01:00