• Philipp Tomsich's avatar
    tools: omapimage: fix corner-case in byteswap path · c8e1ca3e
    Philipp Tomsich authored
    Since commit 2614a208 ("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: 2614a208 ("common: command: tempory buffer should have size of command line buf")
    Fixes: 79b9ebb7 ("omapimage: Add support for byteswapped SPI images")
    Signed-off-by: default avatarPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>
    Reviewed-by: default avatarMartin Elshuber <martin.elshuber@theobroma-systems.com>
    c8e1ca3e
Name
Last commit
Last update
..
binman Loading commit data...
buildman Loading commit data...
dtoc Loading commit data...
easylogo Loading commit data...
env Loading commit data...
gdb Loading commit data...
kermit Loading commit data...
libfdt Loading commit data...
logos Loading commit data...
omap Loading commit data...
patman Loading commit data...
scripts Loading commit data...
.gitignore Loading commit data...
Makefile Loading commit data...
aisimage.c Loading commit data...
aisimage.h Loading commit data...
atmel_pmecc_params.c Loading commit data...
atmelimage.c Loading commit data...
bmp_logo.c Loading commit data...
default_image.c Loading commit data...
dumpimage.c Loading commit data...
dumpimage.h Loading commit data...
envcrc.c Loading commit data...
fdt_host.h Loading commit data...
fdtgrep.c Loading commit data...
fit_check_sign.c Loading commit data...
fit_common.c Loading commit data...
fit_common.h Loading commit data...
fit_image.c Loading commit data...
fit_info.c Loading commit data...
gen_eth_addr.c Loading commit data...
gen_ethaddr_crc.c Loading commit data...
genboardscfg.py Loading commit data...
getline.c Loading commit data...
getline.h Loading commit data...
gpheader.h Loading commit data...
gpimage-common.c Loading commit data...
gpimage.c Loading commit data...
ifdtool.c Loading commit data...
ifdtool.h Loading commit data...
image-host.c Loading commit data...
imagetool.c Loading commit data...
imagetool.h Loading commit data...
img2brec.sh Loading commit data...
img2srec.c Loading commit data...
imximage.c Loading commit data...
jtagconsole Loading commit data...
kwbimage.c Loading commit data...
kwbimage.h Loading commit data...
kwboot.c Loading commit data...
lpc32xximage.c Loading commit data...
microcode-tool Loading commit data...
microcode-tool.py Loading commit data...
mingw_support.c Loading commit data...
mingw_support.h Loading commit data...
mips-relocs.c Loading commit data...
mkenvimage.c Loading commit data...
mkexynosspl.c Loading commit data...
mkimage.c Loading commit data...
mkimage.h Loading commit data...
mksunxiboot.c Loading commit data...
moveconfig.py Loading commit data...
mxsboot.c Loading commit data...
mxsimage.c Loading commit data...
mxsimage.h Loading commit data...
ncb.c Loading commit data...
netconsole Loading commit data...
omapimage.c Loading commit data...
omapimage.h Loading commit data...
os_support.c Loading commit data...
os_support.h Loading commit data...
pbl_crc32.c Loading commit data...
pbl_crc32.h Loading commit data...
pblimage.c Loading commit data...
pblimage.h Loading commit data...
proftool.c Loading commit data...
relocate-rela.c Loading commit data...
rkcommon.c Loading commit data...
rkcommon.h Loading commit data...
rkimage.c Loading commit data...
rkmux.py Loading commit data...
rksd.c Loading commit data...
rkspi.c Loading commit data...
socfpgaimage.c Loading commit data...
sunxi-spl-image-builder.c Loading commit data...
ublimage.c Loading commit data...
ublimage.h Loading commit data...
ubsha1.c Loading commit data...
vybridimage.c Loading commit data...
xway-swap-bytes.c Loading commit data...
zynqimage.c Loading commit data...
zynqmpimage.c Loading commit data...