summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRon <ron@debian.org>2009-06-27 04:44:28 +0930
committerAustin Foxley <austinf@cetoncorp.com>2009-07-09 01:36:17 -0700
commit83285a67dca1a4988ce77299ea982ddb63feab20 (patch)
tree8605993c4ce5530bd3f208625bd3d6101e2aa9af
parentc06d418fa75cc20a3f12576818b4d77f1c4cfdcb (diff)
downloaduClibc-alpine-83285a67dca1a4988ce77299ea982ddb63feab20.tar.bz2
uClibc-alpine-83285a67dca1a4988ce77299ea982ddb63feab20.tar.xz
Avoid type-punned pointers that break strict-aliasing
Signed-off-by: Ron Lee <ron@debian.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
-rw-r--r--ldso/ldso/dl-elf.c4
-rw-r--r--ldso/ldso/dl-startup.c3
-rw-r--r--libc/inet/getaddrinfo.c9
3 files changed, 11 insertions, 5 deletions
diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
index 7be47e184..7bf3145b6 100644
--- a/ldso/ldso/dl-elf.c
+++ b/ldso/ldso/dl-elf.c
@@ -341,6 +341,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
ElfW(Addr) relro_addr = 0;
size_t relro_size = 0;
struct stat st;
+ uint32_t *p32;
DL_LOADADDR_TYPE lib_loadaddr;
DL_INIT_LOADADDR_EXTRA_DECLS
@@ -385,7 +386,8 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
_dl_read(infile, header, _dl_pagesize);
epnt = (ElfW(Ehdr) *) (intptr_t) header;
- if (*((uint32_t*) &epnt->e_ident) != ELFMAG_U32) {
+ p32 = (uint32_t*)&epnt->e_ident;
+ if (*p32 != ELFMAG_U32) {
_dl_dprintf(2, "%s: '%s' is not an ELF file\n", _dl_progname,
libname);
_dl_internal_error_number = LD_ERROR_NOTELF;
diff --git a/ldso/ldso/dl-startup.c b/ldso/ldso/dl-startup.c
index ccd997db3..6f07b960a 100644
--- a/ldso/ldso/dl-startup.c
+++ b/ldso/ldso/dl-startup.c
@@ -121,6 +121,7 @@ DL_START(unsigned long args)
struct elf_resolve *tpnt = &tpnt_tmp;
ElfW(auxv_t) auxvt[AT_EGID + 1];
ElfW(Dyn) *dpnt;
+ uint32_t *p32;
/* WARNING! -- we cannot make _any_ function calls until we have
* taken care of fixing up our own relocations. Making static
@@ -176,7 +177,7 @@ DL_START(unsigned long args)
/* Do not use an inline _dl_strncmp here or some arches
* will blow chunks, i.e. those that need to relocate all
* string constants... */
- || *((uint32_t*) &header->e_ident) != ELFMAG_U32
+ || *(p32 = (uint32_t*)&header->e_ident) != ELFMAG_U32
) {
SEND_EARLY_STDERR("Invalid ELF header\n");
_dl_exit(0);
diff --git a/libc/inet/getaddrinfo.c b/libc/inet/getaddrinfo.c
index 0ac29e662..e3016f63c 100644
--- a/libc/inet/getaddrinfo.c
+++ b/libc/inet/getaddrinfo.c
@@ -543,7 +543,8 @@ gaih_inet(const char *name, const struct gaih_service *service,
if (scope_delim != NULL) {
int try_numericscope = 0;
- if (IN6_IS_ADDR_LINKLOCAL(at->addr) || IN6_IS_ADDR_MC_LINKLOCAL(at->addr)) {
+ uint32_t *a32 = (uint32_t*)at->addr;
+ if (IN6_IS_ADDR_LINKLOCAL(a32) || IN6_IS_ADDR_MC_LINKLOCAL(at->addr)) {
at->scopeid = if_nametoindex(scope_delim + 1);
if (at->scopeid == 0)
try_numericscope = 1;
@@ -621,8 +622,10 @@ gaih_inet(const char *name, const struct gaih_service *service,
#endif
if (req->ai_family == 0 || req->ai_family == AF_INET) {
atr->family = AF_INET;
- if ((req->ai_flags & AI_PASSIVE) == 0)
- *(uint32_t*)atr->addr = htonl(INADDR_LOOPBACK);
+ if ((req->ai_flags & AI_PASSIVE) == 0) {
+ uint32_t *a = (uint32_t*)atr->addr;
+ *a = htonl(INADDR_LOOPBACK);
+ }
}
}