summaryrefslogtreecommitdiff
path: root/ldso/util
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-02-13 07:25:03 +0000
committerEric Andersen <andersen@codepoet.org>2002-02-13 07:25:03 +0000
commit98cba6e7dd947aec0d4cf6e61f2f31318ac919e1 (patch)
treef12f458769704ba0aee0b668b3cbcf3e706837cb /ldso/util
parentce4b0fa7e84539992a0cccb618c4fc9d9cfabc50 (diff)
Fix silly buffer overflow
Diffstat (limited to 'ldso/util')
-rw-r--r--ldso/util/ldd.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ldso/util/ldd.c b/ldso/util/ldd.c
index 68221faab..f9cdd8da0 100644
--- a/ldso/util/ldd.c
+++ b/ldso/util/ldd.c
@@ -38,6 +38,9 @@
#include <sys/stat.h>
#include <sys/types.h>
#include "elf.h"
+#ifdef DMALLOC
+#include <dmalloc.h>
+#endif
struct library {
char *name;
@@ -252,7 +255,7 @@ static int add_library(Elf32_Ehdr* ehdr, Elf32_Dyn* dynamic, char *strtab, int i
newlib = malloc(sizeof(struct library));
if (!newlib)
return 1;
- newlib->name = malloc(strlen(s));
+ newlib->name = malloc(strlen(s)+1);
strcpy(newlib->name, s);
newlib->resolved = 0;
newlib->path = NULL;
@@ -317,7 +320,7 @@ static void find_elf_interpreter(Elf32_Ehdr* ehdr, Elf32_Dyn* dynamic, char *str
newlib = malloc(sizeof(struct library));
if (!newlib)
return;
- newlib->name = malloc(strlen(s));
+ newlib->name = malloc(strlen(s)+1);
strcpy(newlib->name, s);
newlib->path = newlib->name;
newlib->resolved = 1;