| Commit message (Expand) | Author | Age | Files | Lines |
| * | fix argument types for legacy function inet_makeaddr•••the type int was taken from seemingly erroneous man pages. glibc uses
in_addr_t (uint32_t), and semantically, the arguments should be
unsigned.
| Rich Felker | 2014-01-06 | 1 | -2/+1 |
| * | implement legacy function herror•••based on patch by Timo Teräs; greatly simplified to use fprintf.
| Rich Felker | 2013-12-20 | 1 | -0/+8 |
| * | include cleanups: remove unused headers and add feature test macros | Szabolcs Nagy | 2013-12-12 | 13 | -18/+3 |
| * | remove an unnecessary check in inet_pton•••at most 4 hexadecimal digits are processed in one field so the
value cannot overflow. the netdb.h header was not used.
| Szabolcs Nagy | 2013-12-12 | 1 | -2/+1 |
| * | support mix of IPv4 and v6 nameservers in resolv.conf•••a v6 socket will only be used if there is at least one v6 nameserver
address. if the kernel lacks v6 support, the code will fall back to
using a v4 socket and requests to v6 servers will silently fail. when
using a v6 socket, v4 addresses are converted to v4-mapped form and
setsockopt is used to ensure that the v6 socket can accept both v4 and
v6 traffic (this is on-by-default on Linux but the default is
configurable in /proc and so it needs to be set explicitly on the
socket level). this scheme avoids increasing resource usage during
lookups and allows the existing network io loop to be used without
modification.
previously, nameservers whose address family did not match the address
family of the first-listed nameserver were simply ignored. prior to
recent __ipparse fixes, they were not ignored but erroneously parsed.
| Rich Felker | 2013-11-30 | 1 | -5/+31 |
| * | reject invalid address families in getaddrinfo•••subsequent code assumes the address family requested is either
unspecified or one of IPv4/IPv6, and could malfunction if this
constraint is not met, so other address families should be explicitly
rejected.
| Rich Felker | 2013-11-27 | 1 | -0/+3 |
| * | remove duplicate includes from dynlink.c, strfmon.c and getaddrinfo.c | Szabolcs Nagy | 2013-11-25 | 1 | -3/+0 |
| * | Fix dn_comp prototype and add stub•••This function is used by ping6 from iputils.
| Michael Forney | 2013-11-24 | 1 | -0/+9 |
| * | Fix dn_expand pointer following | Michael Forney | 2013-11-23 | 1 | -1/+1 |
| * | fix fd leak (missing close-on-exec) in getifaddrs | Rich Felker | 2013-11-20 | 1 | -1/+1 |
| * | fix regression in inet_aton due to misinterpretation of __ipparse return•••inet_aton returns a boolean success value, whereas __ipparse returns 0
on success and -1 on failure. also change the conditional in inet_addr
to be consistent with other uses of __ipparse where only negative
values are treated as failure.
| Rich Felker | 2013-11-02 | 2 | -3/+3 |
| * | fix inet_pton•••* parse IPv4 dotted-decimal correctly (without strtoul, no leading zeros)
* disallow single leading ':' in IPv6 address
* allow at most 4 hex digits in IPv6 address (according to RFC 2373)
* have enough hex fields in IPv4 mapped IPv6 address
* disallow leading zeros in IPv4 mapped IPv6 address
| Szabolcs Nagy | 2013-10-23 | 1 | -26/+19 |
| * | fix __ipparse to parse the generic numbers-and-dots IPv4 format correctly•••* allow at most 4 parts
* bounds check the parts correctly
* disallow leading whitespace and sign
* check the address family before falling back to IPv6
| Szabolcs Nagy | 2013-10-22 | 1 | -5/+12 |
| * | fix inet_aton to accept the generic "numbers-and-dots" IPv4 address format | Szabolcs Nagy | 2013-10-22 | 1 | -1/+4 |
| * | split inet_addr and inet_ntoa back into their own files•••despite being practically deprecated, these functions are still part
of the standard and thus cannot reside in a file that also contains
namespace pollution. this reverts some of the changes made in commit
e40f48a421a9176e3e298b5bac75f0355b219e58.
| Rich Felker | 2013-10-21 | 3 | -16/+21 |
| * | fix return value for inet_pton in ipv6 failure cases•••in the case of input that does not match the expected form, the
correct return value is 0, not -1.
| Rich Felker | 2013-10-19 | 1 | -6/+6 |
| * | fix regression in dn_expand/reverse dns•••off-by-one error copying the name components was yielding junk at the
beginning and truncating one character at the end (of every
component).
| Rich Felker | 2013-08-23 | 1 | -1/+1 |
| * | fix length computation in dn_expand•••there are two possible points where the length is evaluated: either
the first 'compression' jump, or the null terminator if no jumps have
taken place yet. the previous code only measured the length of the
first component.
| Rich Felker | 2013-08-14 | 1 | -3/+5 |
| * | de-duplicate dn_expand, fix return value and signature, clean up•••the duplicate code in dn_expand and its incorrect return values are
both results of the history of the code: the version in __dns.c was
originally written with no awareness of the legacy resolver API, and
was later copy-and-paste duplicated to provide the legacy API.
this commit is the first of a series that will restructure the
internal dns code to share as much code as possible with the legacy
resolver API functions.
I have also removed the loop detection logic, since the output buffer
length limit naturally prevents loops. in order to avoid long runtime
when encountering a loop if the caller provided a ridiculously long
buffer, the caller-provided length is clamped at the maximum dns name
length.
| Rich Felker | 2013-08-14 | 2 | -48/+23 |
| * | fix undefined strcpy call in inet_ntop•••source and dest arguments for strcpy cannot overlap, so memmove must
be used here. the length is already known from the above loop.
| Rich Felker | 2013-07-25 | 1 | -1/+1 |
| * | make inet_ntop format v4-mapped ipv6 addresses properly•••based on a patch by orc. POSIX actually fails to specify the format of
the ntop conversion; presumably, any output that will correctly
round-trip back via the (well-specified) pton operation is acceptable.
the new behavior is much more convenient than the old, however.
this patch also affects getnameinfo, which is implemented in terms of
inet_ntop and which is the preferred interface for performing this
conversion.
I've also removed some inexplicable cruft (filling the buffer with 'x'
before doing anything) whose origin I was unable to track down.
| Rich Felker | 2013-07-25 | 1 | -8/+14 |
| * | make getaddrinfo with AF_UNSPEC and null host return both IPv4 and v6•••based on a patch by orc, with indexing and flow control cleaned up a
little bit. this code is all going to be replaced at some point in the
near future.
| Rich Felker | 2013-07-24 | 1 | -14/+23 |
| * | fix missing SOCK_CLOEXEC in various functions that use sockets internally | Rich Felker | 2013-07-09 | 4 | -4/+4 |
| * | add stubs for additional legacy ether.h functions•••these would not be expensive to actually implement, but reading
/etc/ethers does not sound like a particularly useful feature, so for
now I'm leaving them as stubs.
| Rich Felker | 2013-07-01 | 1 | -0/+15 |
| * | implement inet_lnaof, inet_netof, and inet_makeaddr•••also move all legacy inet_* functions into a single file to avoid
wasting object file and compile time overhead on them.
the added functions are legacy interfaces for working with classful
ipv4 network addresses. they have no modern usefulness whatsoever, but
some programs unconditionally use them anyway, and they're tiny.
| Rich Felker | 2013-06-25 | 5 | -39/+55 |
| * | add ether_aton[_r] and ether_ntoa[_r] functions•••based on patch by Strake with minor stylistic changes, and combined
into a single file. this patch remained open for a long time due to
some question as to whether ether_aton would be better implemented in
terms of sscanf, and it's time something was committed, so here it is.
| Rich Felker | 2013-06-25 | 1 | -0/+43 |
| * | getifaddrs: implement proper ipv6 netmasks | rofl0r | 2013-04-09 | 1 | -2/+11 |
| * | getifaddrs: remove unused label | rofl0r | 2013-04-06 | 1 | -1/+0 |
| * | getifaddrs: use if_nameindex to enumerate interfaces | rofl0r | 2013-04-05 | 1 | -23/+9 |
| * | getifaddrs: one less indent level | rofl0r | 2013-04-05 | 1 | -30/+28 |
| * | getifaddrs: less malloc | rofl0r | 2013-04-05 | 1 | -55/+52 |
| * | add getifaddrs•••supports ipv4 and ipv6, but not the "extended" usage where
usage statistics and other info are assigned to ifa_data members
of duplicate entries with AF_PACKET family.
| rofl0r | 2013-04-05 | 1 | -0/+191 |
| * | implement dn_skipname (legacy resolver function) | Rich Felker | 2013-04-04 | 1 | -0/+12 |
| * | dynamically allocate storage for gethostby* buffers•••this change shaves ~1k off libc.so bss size, and also avoids hard
errors in the case where the static buffer was not large enough to
hold the result.
this whole framework is really ugly and might should be replaced or at
least heavily overhauled when some changes/factorizations are made to
getaddrinfo internals in the future.
| Rich Felker | 2013-02-02 | 2 | -10/+32 |
| * | fix blank ai_canonname from getaddrinfo for non-CNAMEs | Rich Felker | 2013-02-02 | 1 | -1/+1 |
| * | fix memory leak due to double call to getaddrinfo in gethostbyname* | Rich Felker | 2013-02-02 | 1 | -1/+0 |
| * | fix error returns in gethostby*_r functions•••they're supposed to return an error code rather than using errno.
| Rich Felker | 2013-02-02 | 2 | -17/+10 |
| * | add inet_network (required for wine) | rofl0r | 2012-12-19 | 1 | -0/+11 |
| * | improve SOCK_NONBLOCK/SOCK_CLOEXEC fallback code•••checking for EINVAL should be sufficient, but qemu user emulation
returns EPROTONOSUPPORT in some of the failure cases, and it seems
conceivable that other kernels doing linux-emulation could make the
same mistake. since DNS lookups and other important code might break
if the fallback does not get invoked, be extra careful and check for
either error.
note that it's important NOT to perform the fallback code on other
errors such as resource-exhaustion cases, since the fallback is not
atomic and will lead to file-descriptor leaks in multi-threaded
programs that use exec. the fallback code is only "safe" to run when
the initial failure is caused by the application's choice of
arguments, not the system state.
| Rich Felker | 2012-11-05 | 1 | -1/+2 |
| * | fix some more O_CLOEXEC/SOCK_CLOEXEC issues | Rich Felker | 2012-09-29 | 1 | -3/+1 |
| * | move accept4, dup3, and pipe2 to non-linux-specific locations•••these interfaces have been adopted by the Austin Group for inclusion
in the next version of POSIX.
| Rich Felker | 2012-09-29 | 1 | -0/+9 |
| * | emulate SOCK_CLOEXEC and SOCK_NONBLOCK for old (pre-2.6.27) kernels•••also update syslog to use SOCK_CLOEXEC rather than separate fcntl
step, to make it safe in multithreaded programs that run external
programs.
emulation is not atomic; it could be made atomic by holding a lock on
forking during the operation, but this seems like overkill. my goal is
not to achieve perfect behavior on old kernels (which have plenty of
other imperfect behavior already) but to avoid catastrophic breakage
in (1) syslog, which would give no output on old kernels with the
change to use SOCK_CLOEXEC, and (2) programs built on a new kernel
where configure scripts detected a working SOCK_CLOEXEC, which later
get run on older kernels (they may otherwise fail to work completely).
| Rich Felker | 2012-09-29 | 1 | -1/+14 |
| * | fix getaddrinfo to accept port 0 (zero)•••new behavior can be summarized as:
inputs that parse completely as a decimal number are treated as one,
and rejected only if the result is out of 16-bit range.
inputs that do not parse as a decimal number (where strtoul leaves
anything left over in the input) are searched in /etc/services.
| Rich Felker | 2012-09-22 | 1 | -2/+2 |
| * | use restrict everywhere it's required by c99 and/or posix 2008•••to deal with the fact that the public headers may be used with pre-c99
compilers, __restrict is used in place of restrict, and defined
appropriately for any supported compiler. we also avoid the form
[restrict] since older versions of gcc rejected it due to a bug in the
original c99 standard, and instead use the form *restrict.
| Rich Felker | 2012-09-06 | 9 | -11/+11 |
| * | remove scanf dependency from getaddrinfo /etc/services support | Rich Felker | 2012-07-22 | 1 | -5/+4 |
| * | getaddrinfo /etc/services lookup support | Rich Felker | 2012-07-22 | 1 | -3/+16 |
| * | make getservby*_r return error code rather than -1 (and using errno)•••untested but should be correct..
| Rich Felker | 2012-07-22 | 2 | -19/+35 |
| * | fix logic error for skipping failed interfaces in if_nameindex | Rich Felker | 2012-07-21 | 1 | -8/+7 |
| * | fix getservby*() with null pointer for protocol argument•••not sure this is the best fix but it should work
| Rich Felker | 2012-07-14 | 2 | -0/+8 |
| * | workaround another sendmsg kernel bug on 64-bit machines•••the kernel wrongly expects the cmsg length field to be size_t instead
of socklen_t. in order to work around the issue, we have to impose a
length limit and copy to a local buffer. the length limit should be
more than sufficient for any real-world use; these headers are only
used for passing file descriptors and permissions between processes
over unix sockets.
| Rich Felker | 2012-07-12 | 1 | -0/+13 |