diff options
author | H. Peter Anvin <hpa@zytor.com> | 2007-04-26 15:24:41 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2007-04-26 15:24:41 -0700 |
commit | 7a0f2a3409580030f60f0bf2b351dd701f868b5a (patch) | |
tree | 07a1f55ccd794d236cbd28ab54023b9164faa548 /com32/modules/linux.c | |
parent | 595705ffad4f63cfeb84e9bb1243df03808c2fff (diff) | |
download | syslinux-7a0f2a3409580030f60f0bf2b351dd701f868b5a.tar.gz syslinux-7a0f2a3409580030f60f0bf2b351dd701f868b5a.tar.xz syslinux-7a0f2a3409580030f60f0bf2b351dd701f868b5a.zip |
linux.c32: saturate memory size to 32 bits if too large
Diffstat (limited to 'com32/modules/linux.c')
-rw-r--r-- | com32/modules/linux.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/com32/modules/linux.c b/com32/modules/linux.c index f1db8c87..c20536f3 100644 --- a/com32/modules/linux.c +++ b/com32/modules/linux.c @@ -99,6 +99,12 @@ static unsigned long long suffix_number(const char *str) return v; } +/* Truncate to 32 bits, with saturate */ +static inline uint32_t saturate32(unsigned long long v) +{ + return (v > 0xffffffff) ? 0xffffffff : (uint32_t)v; +} + /* Stitch together the command line from a set of argv's */ static char *make_cmdline(char **argv) { @@ -196,7 +202,7 @@ int main(int argc, char *argv[]) /* Look for specific command-line arguments we care about */ if ((arg = find_argument(argp, "mem="))) - mem_limit = suffix_number(arg); + mem_limit = saturate32(suffix_number(arg)); if ((arg = find_argument(argp, "vga="))) video_mode = strtoul(arg, NULL, 0); |