1880 Commits

Author SHA1 Message Date
Rich Felker
7dd60b80f9 fix bug in synccall with no threads: lock was taken but never released 2011-07-30 00:24:26 -04:00
Rich Felker
afade2356e add setxid.c for new set*id() framework. missed in last commit. 2011-07-29 23:10:07 -04:00
Rich Felker
acb0480662 new attempt at making set*id() safe and robust
changing credentials in a multi-threaded program is extremely
difficult on linux because it requires synchronizing the change
between all threads, which have their own thread-local credentials on
the kernel side. this is further complicated by the fact that changing
the real uid can fail due to exceeding RLIMIT_NPROC, making it
possible that the syscall will succeed in some threads but fail in
others.

the old __rsyscall approach being replaced was robust in that it would
report failure if any one thread failed, but in this case, the program
would be left in an inconsistent state where individual threads might
have different uid. (this was not as bad as glibc, which would
sometimes even fail to report the failure entirely!)

the new approach being committed refuses to change real user id when
it cannot temporarily set the rlimit to infinity. this is completely
POSIX conformant since POSIX does not require an implementation to
allow real-user-id changes for non-privileged processes whatsoever.
still, setting the real uid can fail due to memory allocation in the
kernel, but this can only happen if there is not already a cached
object for the target user. thus, we forcibly serialize the syscalls
attempts, and fail the entire operation on the first failure. this
*should* lead to an all-or-nothing success/failure result, but it's
still fragile and highly dependent on kernel developers not breaking
things worse than they're already broken.

ideally linux will eventually add a CLONE_USERCRED flag that would
give POSIX conformant credential changes without any hacks from
userspace, and all of this code would become redundant and could be
removed ~10 years down the line when everyone has abandoned the old
broken kernels. i'm not holding my breath...
2011-07-29 22:59:44 -04:00
Rich Felker
aed707f679 remove ugly prng from mk*temp and just re-poll time on retry 2011-07-28 22:03:54 -04:00
Rich Felker
bbdcc403ca eliminate mk*temp dependency on snprintf
this helps some tiny programs be even more tiny, and barly increases
code size even if both are used.
2011-07-28 21:48:53 -04:00
Rich Felker
649af9f73a fix for setenv bogus var argument handling
thanks to mikachu

per POSIX:

The setenv() function shall fail if:

[EINVAL] The name argument is a null pointer, points to an empty
string, or points to a string containing an '=' character.
2011-07-28 20:43:40 -04:00
Rich Felker
e01ac67599 when resolving symbols with only weak defs, use first def, not last def 2011-07-25 09:22:05 -04:00
Rich Felker
dd92a09eca comment non-obvious de bruijn sequence code in int parser 2011-07-25 09:21:40 -04:00
Rich Felker
427173b932 fix resolution of weak symbols (hopefully right now) and vdso 2011-07-24 02:19:47 -04:00
Rich Felker
e91c375fd0 workaround for gcc's optimizer breaking dynamic symbol resolution 2011-07-24 01:10:01 -04:00
Rich Felker
6ab444d97a load vdso, if present, into the dso list 2011-07-24 00:54:55 -04:00
Rich Felker
f7adc39e37 const correctness on function pointer 2011-07-24 00:54:36 -04:00
Rich Felker
a53de812d2 simplify dynamic linker startup
instead of creating temp dso objects on the stack and moving them to
the heap if dlopen/dlsym are used, use static objects to begin with,
and just donate them to malloc if we no longer need them.
2011-07-24 00:26:12 -04:00
Rich Felker
e3eb49321c some preliminaries for vdso clock support
these changes also make it so clock_gettime(CLOCK_REALTIME, &ts) works
even on pre-2.6 kernels, emulated via the gettimeofday syscall. there
is no cost for the fallback check, as it falls under the error case
that already must be checked for storing the error code in errno, but
which would normally be hidden inside __syscall_ret.
2011-07-23 23:45:33 -04:00
Rich Felker
c0fe5b9da9 check for fd exhaustion in forkpty
we cannot report failure after forking, so the idea is to ensure prior
to fork that fd 0,1,2 exist. this will prevent dup2 from possibly
hitting a resource limit and failing in the child process. fcntl
rather than dup2 is used prior to forking to avoid race conditions.
2011-07-22 00:25:56 -04:00
Rich Felker
d40e344f7b incorrect check for open failure in openpty function
-1, not 0, indicates failure
2011-07-22 00:23:36 -04:00
Rich Felker
63d447e2a3 socket headers macro adjustment - workaround for buggy programs
some program was undefining AF_NETLINK and thereby breaking AF_ROUTE...
2011-07-21 22:44:05 -04:00
Rich Felker
fa845669ce fix errno value when fdopendir is given an invalid file descriptor
this resolves an issue reported by Vasiliy Kulikov
2011-07-21 21:15:14 -04:00
Rich Felker
4ec07e1f60 ensure in fork that child gets its own new robust mutex list 2011-07-16 23:17:17 -04:00
Rich Felker
94a0171d80 fix logic error in fread
fread was calling f->read without checking that the file was in
reading mode. this could:
1. crash, if f->read was a null pointer
2. cause unwanted blocking on a terminal already at eof
3. allow reading on a write-only file
2011-07-16 21:24:02 -04:00
Rich Felker
47d027ee1a fix various bugs in new integer parser framework
1. my interpretation of subject sequence definition was wrong. adjust
parser to conform to the standard.

2. some code for handling tail overflow case was missing (forgot to
finish writing it).

3. typo (= instead of ==) caused ERANGE to wrongly behave like EINVAL
2011-07-14 22:11:00 -04:00
Rich Felker
d3fd192523 fix wcsto[iu]max with high characters
stopping without letting the parser see a stop character prevented
getting a result. so treat all high chars as the null character and
pass them into the parser.

also eliminated ugly tmp var using compound literals.
2011-07-14 01:12:05 -04:00
Rich Felker
ecc9c5fcfa new restartable integer parsing framework.
this fixes a number of bugs in integer parsing due to lazy haphazard
wrapping, as well as some misinterpretations of the standard. the new
parser is able to work character-at-a-time or on whole strings, making
it easy to support the wide functions without unbounded space for
conversion. it will also be possible to update scanf to use the new
parser.
2011-07-14 00:51:45 -04:00
Rich Felker
0e2331c9b6 gb18030 support in iconv (only from, not to)
also support (and restrict to subsets) older chinese sets, and
explicitly refuse to convert to cjk (since there's no code for it yet)
2011-07-12 20:30:04 -04:00
Rich Felker
c3c5e88c31 "implement" getnetbyaddr and getnetbyname
these are useless legacy functions but some old software contains
cruft that expects them to exist...
2011-07-12 02:52:06 -04:00
Rich Felker
95a85e047e legacy japanese charset support in iconv (only from, not to) 2011-07-12 02:43:24 -04:00
Rich Felker
594b16e004 simplify iconv and support more legacy codepages 2011-07-12 00:31:39 -04:00
Rich Felker
6b1d3817cf add missing signalfd flags 2011-07-09 18:06:59 -04:00
Rich Felker
a9e6d01114 printf: "if a precision is specified, the '0' flag shall be ignored." 2011-07-04 11:55:52 -04:00
Rich Felker
cc44d9f201 zero precision with zero value should not inhibit prefix/width printing 2011-07-04 01:57:00 -04:00
Rich Felker
3d54adbe47 printf("%#x",0) should print 0 not 0x0 2011-07-04 01:01:58 -04:00
Rich Felker
2f0c415ceb iconv was not returning -1 on most failure
this broke most uses of iconv in real-world programs, especially
glib's iconv wrappers.
2011-07-03 19:26:12 -04:00
Rich Felker
58483f0afd 0.7.12 release notes 2011-07-03 16:41:20 -04:00
Rich Felker
2fdea17c3d fix dlopen UB due to longjmp/volatile rules violation 2011-07-01 22:40:00 -04:00
Rich Felker
e936e4612f res_search symbol, aliased to res_query for now (better than nothing) 2011-06-30 23:12:07 -04:00
Rich Felker
191ebcac31 simple rpath support (no token expansion yet) for dynamic linker 2011-06-30 23:02:27 -04:00
Rich Felker
17be829104 fill in junk in stropts.h
STREAMS are utterly useless as far as I can tell, but some software
was apparently broken by the presence of stropts.h but lack of macros
it's supposed to define...
2011-06-30 20:23:24 -04:00
Rich Felker
daaef3552d fix error in previous ld80 fpclassify commit 2011-06-30 16:37:51 -04:00
Rich Felker
f6fd351c70 catch invalid ld80 bit patterns and treat them as nan
this should not be necessary - the invalid bit patterns cannot be
created except through type punning. however, some broken gnu software
is passing them to printf and triggering dangerous stack-smashing, so
let's catch them anyway...
2011-06-30 16:31:43 -04:00
Rich Felker
e5cb55fedd fix logic in __fwriting 2011-06-30 13:27:08 -04:00
Rich Felker
a0b56b947a add and consolidate nasty stdio_ext junk
hopefully this resolves the rest of the issues with hideously
nonportable hacks in programs that use gnulib.
2011-06-30 12:44:48 -04:00
Rich Felker
7640497f5f implement the nonstandard GNU function fpurge
this is a really ugly and backwards function, but its presence will
prevent lots of broken gnulib software from trying to define its own
version of fpurge and thereby failing to build or worse.
2011-06-30 11:42:33 -04:00
Rich Felker
fb62ae74d0 fix buffer overrun in getgrent code when there are no group members 2011-06-30 08:11:06 -04:00
Rich Felker
f9ed11f3e1 posix_memalign should fail if size is not a multiple of sizeof(void *) 2011-06-29 19:26:30 -04:00
Rich Felker
47e72e10d5 avoid errors in ucontext.h when no feature test macros are defined 2011-06-29 17:13:01 -04:00
Rich Felker
f7dff1852b locking support for random() prng
these interfaces are required to be thread-safe even though they are
not state-free. the random number sequence is shared across all
threads.
2011-06-29 15:29:52 -04:00
Rich Felker
af3d5405b8 work around linux bug in mprotect
per POSIX: The mprotect() function shall change the access protections
to be that specified by prot for those whole pages containing any part
of the address space of the process starting at address addr and
continuing for len bytes.

on the other hand, linux mprotect fails with EINVAL if the base
address and/or length is not page-aligned, so we have to align them
before making the syscall.
2011-06-29 00:42:42 -04:00
Rich Felker
9f17413c75 textrel support, cheap and ugly 2011-06-29 00:29:08 -04:00
Rich Felker
2cee45762a release notes for 0.7.11 2011-06-28 22:06:58 -04:00
Rich Felker
6717e62ac0 reclaim the memory wasted by dynamic linking for use by malloc 2011-06-28 19:40:14 -04:00