Not all sockaddr structs have the same alignment. Instead, it depends
on the fields contained in it. The way net-tools has written things
though, it accepts sockaddr* everywhere which has 16bit alignment, even
though it will cast it to other sockaddr types that have higher alignment.
For example, `route` can crash on alpha because it declares sockaddr on
the stack, but then casts it up to sockaddr_in6 (which has 32bits).
It's also bad storage wise as we might try to cast the sockaddr to a type
that is larger than sockaddr which means clobbering the stack.
Instead, lets rewrite all the APIs to take a sockaddr_storage. This is
guaranteed to have both the maximum alignment and size requirements for
all other sockaddr types. Now we can safely cast that pointer to any
other sockaddr type and not worry about it. It also has the nice effect
of deleting a lot of casts in a lot of places when we only need the type
of family.
The vast majority of changes here are mechanical. There are a few places
where we have to memcpy between a dedicated sockaddr_storage and a smaller
struct because we're using an external embedded type (like arpreq).
URL: https://bugs.gentoo.org/558436
Some of these are unused, so drop them. Others are only used in debug
code, so refactor those so things are always compiled.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
reported)
- Various cleanups and bug fixes.
- Better error message for ENODEV.
- Proper exit codes for interface printing
- Add safe_strncpy and use it everywhere: this fixes quite a lot of
strncpy bugs (strncpy doesn't add a '\0' when the source string is too
long!)
Some other cleanups:
- lib/net-string.c removed because it was not used and had a copyright notice
that conflicted with the GPL.
- Minor cleanups.
- Fix an potential buffer overflow in ax25.
- Switch to CVS $Id$ for versioning consistently
Arnaldo Carvalho de Melo <acme@conectiva.com.br>). This
touches virtually every file but the changes are fairly
superficial.
Please check I haven't broken your favourite AF/hardware
type during the conversion.