From 98cba6e7dd947aec0d4cf6e61f2f31318ac919e1 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Wed, 13 Feb 2002 07:25:03 +0000 Subject: Fix silly buffer overflow --- ldso/util/ldd.c | 7 +++++-- 1 file 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 #include #include "elf.h" +#ifdef DMALLOC +#include +#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; -- cgit v1.2.3