diff options
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/hppa/stand/mkboot/mkboot.c | 7 | ||||
-rw-r--r-- | sys/arch/hppa64/stand/mkboot/mkboot.c | 7 |
2 files changed, 8 insertions, 6 deletions
diff --git a/sys/arch/hppa/stand/mkboot/mkboot.c b/sys/arch/hppa/stand/mkboot/mkboot.c index de84d6b6f44..0dd57973acb 100644 --- a/sys/arch/hppa/stand/mkboot/mkboot.c +++ b/sys/arch/hppa/stand/mkboot/mkboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkboot.c,v 1.18 2014/01/22 09:18:04 jsing Exp $ */ +/* $OpenBSD: mkboot.c,v 1.19 2014/09/24 00:13:13 doug Exp $ */ /* * Copyright (c) 1990, 1993 @@ -204,10 +204,11 @@ putfile(char *from_file, int to) if (n != sizeof (elf_header)) err(1, "%s: reading ELF header", from_file); header_count = ntohs(elf_header.e_phnum); - memory_needed = header_count * sizeof (*elf_segments); - elf_segments = malloc(memory_needed); + elf_segments = reallocarray(NULL, header_count, + sizeof(*elf_segments)); if (elf_segments == NULL) err(1, "malloc"); + memory_needed = header_count * sizeof(*elf_segments); (void) lseek(from, ntohl(elf_header.e_phoff), SEEK_SET); n = read(from, elf_segments, memory_needed); if (n != memory_needed) diff --git a/sys/arch/hppa64/stand/mkboot/mkboot.c b/sys/arch/hppa64/stand/mkboot/mkboot.c index f92a6eabb75..132fd5d6105 100644 --- a/sys/arch/hppa64/stand/mkboot/mkboot.c +++ b/sys/arch/hppa64/stand/mkboot/mkboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkboot.c,v 1.4 2014/01/22 09:26:55 jsing Exp $ */ +/* $OpenBSD: mkboot.c,v 1.5 2014/09/24 00:13:13 doug Exp $ */ /* * Copyright (c) 1990, 1993 @@ -204,10 +204,11 @@ putfile(char *from_file, int to) if (n != sizeof (elf_header)) err(1, "%s: reading ELF header", from_file); header_count = betoh32(elf_header.e_phnum); - memory_needed = header_count * sizeof (*elf_segments); - elf_segments = malloc(memory_needed); + elf_segments = reallocarray(NULL, header_count, + sizeof(*elf_segments)); if (elf_segments == NULL) err(1, "malloc"); + memory_needed = header_count * sizeof(*elf_segments); (void) lseek(from, betoh32(elf_header.e_phoff), SEEK_SET); n = read(from, elf_segments, memory_needed); if (n != memory_needed) |