diff options
author | H. Peter Anvin <hpa@zytor.com> | 2009-06-01 14:47:45 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-06-01 14:47:45 -0700 |
commit | 7b5d546fdbf1d330ecc18d4c5b5d15db7cb5c783 (patch) | |
tree | 0545f8454ce6ba9215c4f322d8ffad401da367ec /lzo | |
parent | d24dee1326c10b0488fe0bdaccb819854a2325c8 (diff) | |
download | syslinux-7b5d546fdbf1d330ecc18d4c5b5d15db7cb5c783.tar.gz syslinux-7b5d546fdbf1d330ecc18d4c5b5d15db7cb5c783.tar.xz syslinux-7b5d546fdbf1d330ecc18d4c5b5d15db7cb5c783.zip |
prepcore: error out if the compressed image is too large to load
Export, from each loader stage, the symbol MaxLMA which indicates to
prepcore how big the image is allowed to be. Change prepcore to
enforce this limit and to error out otherwise.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'lzo')
-rw-r--r-- | lzo/prepcore.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lzo/prepcore.c b/lzo/prepcore.c index cb6b483a..fc1b6c6f 100644 --- a/lzo/prepcore.c +++ b/lzo/prepcore.c @@ -95,6 +95,7 @@ struct prefix { uint32_t pfx_compressed; uint32_t pfx_cdatalen; uint32_t pfx_checksum; + uint32_t pfx_maxlma; }; static inline uint32_t get_32(const uint32_t * p) @@ -317,6 +318,13 @@ int __lzo_cdecl_main main(int argc, char *argv[]) set_32((uint32_t *) (infile + soff + 4), csum); } + if (offset+outfile_len > get_32(&prefix->pfx_maxlma)) { + printf("%s: output too big (%lu, max %lu)\n", + (unsigned long)offset+outfile_len, + (unsigned long)get_32(&prefix->pfx_maxlma)); + exit(1); + } + f = fopen(out_name, "wb"); if (f == NULL) { printf("%s: cannot open output file %s\n", progname, out_name); |