The interfaces documented in this page are purely glibc.
Reported-by: Colin Watson <cjwatson@ubuntu.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
http://sourceware.org/bugzilla/show_bug.cgi?id=7075
Some existing code relies on techniques like the following to
append text to a buffer:
$ cat s.c
#include <stdio.h>
char buf[80] = "not ";
main()
{
sprintf(buf, "%sfail", buf);
puts(buf);
return 0;
}
$ cc s.c
$ ./a.out
not fail
However, the standards say the results are undefined if source
and destination buffers overlap, and with suitable compiler
options, recent changes can cause unexpected results:
$ cc -v 2>&1 | grep gcc
gcc version 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036] (SUSE Linux)
$ cc -D_FORTIFY_SOURCE -O2 s.c
$ ./a.out
fail
Reported-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
It behaved this way at least since "Sun Oct 18 15:02:11 1998 +0000",
some four months after including the nscd implementation in glibc. But
there does seem to be a short window between glibc-2.1 and glibc-2.1.3
when nscd -i was not available, I don't think it's worth muddling the
point of the page with that, though.
Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Glibc's bindresvport() takes no notice of sin->sin_port:
it always returns an arbitrary reserved port in the
anonymous range (512-1023). (Reported by Mats Wichmann.)
Also:
* Add EADDRINUSE and EACCES errors.
* Mention use of getsockname(2).
* Other minor rewrites and reorderings of the text.
* Explicitly note that glib's bindresvport() ignores
sin->sin_port.
* Change license There's now virtually no text remaining from
the 1.70 version of this page.
Reported-by: Mats Wichmann <mats.d.wichmann@intel.com>
Reviewed-by: Mats Wichmann <mats.d.wichmann@intel.com>
Reviewed-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Clean up the $LANGUAGE description, by removing bogus comments
from setlocale(3) and expanding the mention in locale(7).
Maybe you will decide that a more detailed description should be left
to the gettext(3) documentation, but I actually care about the invisible
part of the patch more since the comments have put me off the track
initially ($LANGUAGE has nothing to do with setlocale(3) and is
completely isolated to gettext, as obvious from the glibc sources).
Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
dladdr() will act unexpectedly if called from non-pic code on a
compile-time-generated function pointer:
/* test_dladdr.c */
#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdio.h>
int
main(void)
{
void *func;
Dl_info info = {};
func = printf;
dladdr(func, &info);
printf("%s at %p resolved from %s\n", info.dli_sname,
func, info.dli_fname);
return 0;
}
$ cc test_dladdr.c -ldl
$ ./a.out
printf at 0x804838c resolved from ./a.out
$ cc -fPIC test_dladdr.c -ldl
$ ./a.out
_IO_printf at 0xb7f71c30 resolved from /lib/libc.so.6
In the long term, it might make sense to make dladdr() recognize
plt pointers and recurse, but I'm too afraid of Ulrich ;-)
(and he seems to be heavy proponent of pic code anyway, so
the chances for that to be accepted probably aren't high).
Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This patch documents the order of the getaddrinfo(3) results
(RFC 3484), how should the application deal with that,
mentions the extremely common cause of having multiple
results per query (both IPv4 and IPv6 addresses available)
and mentions /etc/gai.conf.
(mtk: Minor tweaks, and note glibc version for /etc/gai.conf)
Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>