summaryrefslogtreecommitdiff
path: root/kexec
diff options
context:
space:
mode:
Diffstat (limited to 'kexec')
-rw-r--r--kexec/arch/arm/kexec-uImage-arm.c2
-rw-r--r--kexec/arch/i386/kexec-beoboot-x86.c2
-rw-r--r--kexec/arch/i386/kexec-bzImage.c7
-rw-r--r--kexec/arch/i386/kexec-nbi.c2
-rw-r--r--kexec/arch/ppc/kexec-dol-ppc.c3
-rw-r--r--kexec/arch/sh/kexec-uImage-sh.c2
-rw-r--r--kexec/kexec-elf.c16
7 files changed, 19 insertions, 15 deletions
diff --git a/kexec/arch/arm/kexec-uImage-arm.c b/kexec/arch/arm/kexec-uImage-arm.c
index 2291aae..e881fd8 100644
--- a/kexec/arch/arm/kexec-uImage-arm.c
+++ b/kexec/arch/arm/kexec-uImage-arm.c
@@ -12,7 +12,7 @@ int uImage_arm_probe(const char *buf, off_t len)
{
struct image_header header;
- if (len < sizeof(header))
+ if ((uintmax_t)len < (uintmax_t)sizeof(header))
return -1;
memcpy(&header, buf, sizeof(header));
diff --git a/kexec/arch/i386/kexec-beoboot-x86.c b/kexec/arch/i386/kexec-beoboot-x86.c
index dd7f098..27c5a2c 100644
--- a/kexec/arch/i386/kexec-beoboot-x86.c
+++ b/kexec/arch/i386/kexec-beoboot-x86.c
@@ -43,7 +43,7 @@ int beoboot_probe(const char *buf, off_t len)
struct beoboot_header bb_header;
const char *cmdline, *kernel;
int result;
- if (len < sizeof(bb_header)) {
+ if ((uintmax_t)len < (uintmax_t)sizeof(bb_header)) {
return -1;
}
memcpy(&bb_header, buf, sizeof(bb_header));
diff --git a/kexec/arch/i386/kexec-bzImage.c b/kexec/arch/i386/kexec-bzImage.c
index 825beee..c1345d5 100644
--- a/kexec/arch/i386/kexec-bzImage.c
+++ b/kexec/arch/i386/kexec-bzImage.c
@@ -44,7 +44,7 @@ static const int probe_debug = 0;
int bzImage_probe(const char *buf, off_t len)
{
struct x86_linux_header header;
- if (len < sizeof(header)) {
+ if ((uintmax_t)len < (uintmax_t)sizeof(header)) {
return -1;
}
memcpy(&header, buf, sizeof(header));
@@ -119,7 +119,7 @@ int do_bzImage_load(struct kexec_info *info,
/*
* Find out about the file I am about to load.
*/
- if (kernel_len < sizeof(setup_header)) {
+ if ((uintmax_t)kernel_len < (uintmax_t)sizeof(setup_header)) {
return -1;
}
memcpy(&setup_header, kernel, sizeof(setup_header));
@@ -136,7 +136,8 @@ int do_bzImage_load(struct kexec_info *info,
}
if (setup_header.protocol_version >= 0x0206) {
- if (command_line_len > setup_header.cmdline_size) {
+ if ((uintmax_t)command_line_len >
+ (uintmax_t)setup_header.cmdline_size) {
dbgprintf("Kernel command line too long for kernel!\n");
return -1;
}
diff --git a/kexec/arch/i386/kexec-nbi.c b/kexec/arch/i386/kexec-nbi.c
index 469d669..443a3a7 100644
--- a/kexec/arch/i386/kexec-nbi.c
+++ b/kexec/arch/i386/kexec-nbi.c
@@ -74,7 +74,7 @@ int nbi_probe(const char *buf, off_t len)
struct segheader seg;
off_t seg_off;
/* If we don't have enough data give up */
- if ((len < sizeof(hdr)) || (len < 512)) {
+ if (((uintmax_t)len < (uintmax_t)sizeof(hdr)) || (len < 512)) {
return -1;
}
memcpy(&hdr, buf, sizeof(hdr));
diff --git a/kexec/arch/ppc/kexec-dol-ppc.c b/kexec/arch/ppc/kexec-dol-ppc.c
index 429c8ab..83c122a 100644
--- a/kexec/arch/ppc/kexec-dol-ppc.c
+++ b/kexec/arch/ppc/kexec-dol-ppc.c
@@ -265,7 +265,8 @@ int dol_ppc_probe(const char *buf, off_t dol_length)
}
/* end of physical storage must be within file */
- if (dol_sect_offset(h, i) + dol_sect_size(h, i) > dol_length) {
+ if ((uintmax_t)(dol_sect_offset(h, i) + dol_sect_size(h, i)) >
+ (uintmax_t)dol_length) {
if (debug) {
fprintf(stderr,
"%s segment past DOL file size\n",
diff --git a/kexec/arch/sh/kexec-uImage-sh.c b/kexec/arch/sh/kexec-uImage-sh.c
index 869bbd4..c2bce53 100644
--- a/kexec/arch/sh/kexec-uImage-sh.c
+++ b/kexec/arch/sh/kexec-uImage-sh.c
@@ -14,7 +14,7 @@ int uImage_sh_probe(const char *buf, off_t len)
{
struct image_header header;
- if (len < sizeof(header))
+ if ((uintmax_t)len < (uintmax_t)sizeof(header))
return -1;
memcpy(&header, buf, sizeof(header));
diff --git a/kexec/kexec-elf.c b/kexec/kexec-elf.c
index 06695aa..85d1765 100644
--- a/kexec/kexec-elf.c
+++ b/kexec/kexec-elf.c
@@ -98,7 +98,7 @@ unsigned long elf_max_addr(const struct mem_ehdr *ehdr)
static int build_mem_elf32_ehdr(const char *buf, off_t len, struct mem_ehdr *ehdr)
{
Elf32_Ehdr lehdr;
- if (len < sizeof(lehdr)) {
+ if ((uintmax_t)len < (uintmax_t)sizeof(lehdr)) {
/* Buffer is to small to be an elf executable */
if (probe_debug) {
fprintf(stderr, "Buffer is to small to hold ELF header\n");
@@ -170,7 +170,7 @@ static int build_mem_elf32_ehdr(const char *buf, off_t len, struct mem_ehdr *ehd
static int build_mem_elf64_ehdr(const char *buf, off_t len, struct mem_ehdr *ehdr)
{
Elf64_Ehdr lehdr;
- if (len < sizeof(lehdr)) {
+ if ((uintmax_t)len < (uintmax_t)sizeof(lehdr)) {
/* Buffer is to small to be an elf executable */
if (probe_debug) {
fprintf(stderr, "Buffer is to small to hold ELF header\n");
@@ -244,7 +244,7 @@ static int build_mem_ehdr(const char *buf, off_t len, struct mem_ehdr *ehdr)
unsigned char e_ident[EI_NIDENT];
int result;
memset(ehdr, 0, sizeof(*ehdr));
- if (len < sizeof(e_ident)) {
+ if ((uintmax_t)len < (uintmax_t)sizeof(e_ident)) {
/* Buffer is to small to be an elf executable */
if (probe_debug) {
fprintf(stderr, "Buffer is to small to hold ELF e_ident\n");
@@ -387,7 +387,7 @@ static int build_mem_phdrs(const char *buf, off_t len, struct mem_ehdr *ehdr,
return -1;
}
phdr_size *= ehdr->e_phnum;
- if (ehdr->e_phoff + phdr_size > len) {
+ if ((uintmax_t)(ehdr->e_phoff + phdr_size) > (uintmax_t)len) {
/* The program header did not fit in the file buffer */
if (probe_debug) {
fprintf(stderr, "ELF program segment truncated\n");
@@ -420,7 +420,8 @@ static int build_mem_phdrs(const char *buf, off_t len, struct mem_ehdr *ehdr,
*/
phdr = &ehdr->e_phdr[i];
if (!(flags & ELF_SKIP_FILESZ_CHECK)
- && (phdr->p_offset + phdr->p_filesz) > len) {
+ && (uintmax_t)(phdr->p_offset + phdr->p_filesz) >
+ (uintmax_t)len) {
/* The segment does not fit in the buffer */
if (probe_debug) {
fprintf(stderr, "ELF segment not in file\n");
@@ -599,7 +600,7 @@ static int build_mem_shdrs(const char *buf, off_t len, struct mem_ehdr *ehdr,
return -1;
}
shdr_size *= ehdr->e_shnum;
- if (ehdr->e_shoff + shdr_size > len) {
+ if ((uintmax_t)(ehdr->e_shoff + shdr_size) > (uintmax_t)len) {
/* The section header did not fit in the file buffer */
if (probe_debug) {
fprintf(stderr, "ELF section header does not fit in file\n");
@@ -631,7 +632,8 @@ static int build_mem_shdrs(const char *buf, off_t len, struct mem_ehdr *ehdr,
shdr = &ehdr->e_shdr[i];
if (!(flags & ELF_SKIP_FILESZ_CHECK)
&& (shdr->sh_type != SHT_NOBITS)
- && (shdr->sh_offset + shdr->sh_size) > len) {
+ && (uintmax_t)(shdr->sh_offset + shdr->sh_size) >
+ (uintmax_t)len) {
/* The section does not fit in the buffer */
if (probe_debug) {
fprintf(stderr, "ELF section %zd not in file\n",