summaryrefslogtreecommitdiff
path: root/usr.bin/nm
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/nm')
-rw-r--r--usr.bin/nm/elf.c10
-rw-r--r--usr.bin/nm/nm.c8
2 files changed, 9 insertions, 9 deletions
diff --git a/usr.bin/nm/elf.c b/usr.bin/nm/elf.c
index 17559bbb44b..8903b7a351b 100644
--- a/usr.bin/nm/elf.c
+++ b/usr.bin/nm/elf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: elf.c,v 1.17 2007/04/18 19:03:04 miod Exp $ */
+/* $OpenBSD: elf.c,v 1.18 2007/09/02 15:19:33 deraadt Exp $ */
/*
* Copyright (c) 2003 Michael Shalayeff
@@ -27,7 +27,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: elf.c,v 1.17 2007/04/18 19:03:04 miod Exp $";
+static const char rcsid[] = "$OpenBSD: elf.c,v 1.18 2007/09/02 15:19:33 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -148,7 +148,7 @@ elf_load_shdrs(const char *name, FILE *fp, off_t foff, Elf_Ehdr *head)
elf_fix_header(head);
- if ((shdr = malloc(head->e_shentsize * head->e_shnum)) == NULL) {
+ if ((shdr = calloc(head->e_shentsize, head->e_shnum)) == NULL) {
warn("%s: malloc shdr", name);
return (NULL);
}
@@ -174,7 +174,7 @@ elf_load_phdrs(const char *name, FILE *fp, off_t foff, Elf_Ehdr *head)
{
Elf_Phdr *phdr;
- if ((phdr = malloc(head->e_phentsize * head->e_phnum)) == NULL) {
+ if ((phdr = calloc(head->e_phentsize, head->e_phnum)) == NULL) {
warn("%s: malloc phdr", name);
return (NULL);
}
@@ -473,7 +473,7 @@ elf_symloadx(const char *name, FILE *fp, off_t foff, Elf_Ehdr *eh,
MUNMAP(stab, *pstabsize);
return (1);
}
- if ((*psnames = malloc(*pnrawnames * sizeof(np))) == NULL) {
+ if ((*psnames = calloc(*pnrawnames, sizeof(np))) == NULL) {
warn("%s: malloc snames", name);
if (stab)
MUNMAP(stab, *pstabsize);
diff --git a/usr.bin/nm/nm.c b/usr.bin/nm/nm.c
index daf2cfb3715..bb53c435486 100644
--- a/usr.bin/nm/nm.c
+++ b/usr.bin/nm/nm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nm.c,v 1.30 2007/08/06 19:16:06 sobrado Exp $ */
+/* $OpenBSD: nm.c,v 1.31 2007/09/02 15:19:33 deraadt Exp $ */
/* $NetBSD: nm.c,v 1.7 1996/01/14 23:04:03 pk Exp $ */
/*
@@ -42,7 +42,7 @@ static const char copyright[] =
#if 0
static const char sccsid[] = "@(#)nm.c 8.1 (Berkeley) 6/6/93";
#endif
-static const char rcsid[] = "$OpenBSD: nm.c,v 1.30 2007/08/06 19:16:06 sobrado Exp $";
+static const char rcsid[] = "$OpenBSD: nm.c,v 1.31 2007/09/02 15:19:33 deraadt Exp $";
#include <sys/param.h>
#include <sys/mman.h>
@@ -692,12 +692,12 @@ show_file(int count, int warn_fmt, const char *name, FILE *fp, off_t foff, union
nrawnames = head->aout.a_syms / sizeof(*names);
#endif
/* get memory for the symbol table */
- if ((names = malloc(nrawnames * sizeof(struct nlist))) == NULL) {
+ if ((names = calloc(nrawnames, sizeof(struct nlist))) == NULL) {
warn("%s: malloc names", name);
return (1);
}
- if ((snames = malloc(nrawnames * sizeof(struct nlist *))) == NULL) {
+ if ((snames = calloc(nrawnames, sizeof(struct nlist *))) == NULL) {
warn("%s: malloc snames", name);
free(names);
return (1);