-/* $OpenBSD: exec_elf.c,v 1.99 2014/07/12 18:43:32 tedu Exp $ */
+/* $OpenBSD: exec_elf.c,v 1.100 2014/07/13 23:59:58 tedu Exp $ */
/*
* Copyright (c) 1996 Per Fogelstrom
goto bad1;
}
+ ph = mallocarray(eh.e_phnum, sizeof(Elf_Phdr), M_TEMP, M_WAITOK);
phsize = eh.e_phnum * sizeof(Elf_Phdr);
- ph = malloc(phsize, M_TEMP, M_WAITOK);
if ((error = ELFNAME(read_from)(p, nd.ni_vp, eh.e_phoff, (caddr_t)ph,
phsize)) != 0)
* Allocate space to hold all the program headers, and read them
* from the file
*/
+ ph = mallocarray(eh->e_phnum, sizeof(Elf_Phdr), M_TEMP, M_WAITOK);
phsize = eh->e_phnum * sizeof(Elf_Phdr);
- ph = malloc(phsize, M_TEMP, M_WAITOK);
if ((error = ELFNAME(read_from)(p, epp->ep_vp, eh->e_phoff, (caddr_t)ph,
phsize)) != 0)
size_t phsize;
int error;
+ hph = mallocarray(eh->e_phnum, sizeof(Elf_Phdr), M_TEMP, M_WAITOK);
phsize = eh->e_phnum * sizeof(Elf_Phdr);
- hph = malloc(phsize, M_TEMP, M_WAITOK);
if ((error = ELFNAME(read_from)(p, epp->ep_vp, eh->e_phoff,
(caddr_t)hph, phsize)) != 0)
goto out1;
notestart = offset + sizeof(phdr) * cs.npsections;
secstart = notestart + notesize;
- psections = malloc(cs.npsections * sizeof(Elf_Phdr),
+ psections = mallocarray(cs.npsections, sizeof(Elf_Phdr),
M_TEMP, M_WAITOK|M_ZERO);
/* Pass 2: now write the P-section headers. */
-/* $OpenBSD: exec_script.c,v 1.30 2014/07/12 18:43:32 tedu Exp $ */
+/* $OpenBSD: exec_script.c,v 1.31 2014/07/13 23:59:58 tedu Exp $ */
/* $NetBSD: exec_script.c,v 1.13 1996/02/04 02:15:06 christos Exp $ */
/*
epp->ep_flags |= EXEC_INDIR;
/* and set up the fake args list, for later */
- shellargp = malloc(4 * sizeof(char *), M_EXEC, M_WAITOK);
+ shellargp = mallocarray(4, sizeof(char *), M_EXEC, M_WAITOK);
tmpsap = shellargp;
*tmpsap = malloc(shellnamelen + 1, M_EXEC, M_WAITOK);
strlcpy(*tmpsap++, shellname, shellnamelen + 1);