about summary refs log tree commit diff
path: root/src/ldso
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-06-25 12:26:08 -0400
committerRich Felker <dalias@aerifal.cx>2011-06-25 12:26:08 -0400
commit59633c736dcf6dcd11c24edab4803c85b8462bf6 (patch)
tree34394961fa20836399f47e2132a9fc999a3994f3 /src/ldso
parent4d95a58524d277ce51a5d27d964f0628f6e23841 (diff)
downloadmusl-59633c736dcf6dcd11c24edab4803c85b8462bf6.tar.gz
musl-59633c736dcf6dcd11c24edab4803c85b8462bf6.tar.xz
musl-59633c736dcf6dcd11c24edab4803c85b8462bf6.zip
fix possible (questionable) strict aliasing violations and ptr arith
Diffstat (limited to 'src/ldso')
-rw-r--r--src/ldso/dynlink.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index f57485da..56ba89eb 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -123,7 +123,7 @@ static void do_relocs(unsigned char *base, size_t *rel, size_t rel_size, size_t
 
 static void *map_library(int fd, size_t *lenp, unsigned char **basep, size_t *dynp)
 {
-	size_t buf[896/sizeof(size_t)];
+	Ehdr buf[(896+sizeof(Ehdr))/sizeof(Ehdr)];
 	size_t phsize;
 	size_t addr_min=SIZE_MAX, addr_max=0, map_len;
 	size_t this_min, this_max;
@@ -137,11 +137,11 @@ static void *map_library(int fd, size_t *lenp, unsigned char **basep, size_t *dy
 
 	ssize_t l = read(fd, buf, sizeof buf);
 	if (l<sizeof *eh) return 0;
-	eh = (void *)buf;
+	eh = buf;
 	phsize = eh->e_phentsize * eh->e_phnum;
 	if (phsize + sizeof *eh > l) return 0;
 	if (eh->e_phoff + phsize > l) {
-		l = pread(fd, buf+sizeof *eh, phsize, eh->e_phoff);
+		l = pread(fd, buf+1, phsize, eh->e_phoff);
 		if (l != phsize) return 0;
 		eh->e_phoff = sizeof *eh;
 	}