summaryrefslogtreecommitdiff
path: root/lib/libc
Commit message (Collapse)AuthorAgeFilesLines
* When r241373 was merged, one file appears to have been missed from theGavin Atkinson2013-04-021-2/+1
| | | | | | | | | | | | | | | | | | | commit. Merge it: Remove undefined behavior from sranddev() and srandomdev(). This doesn't actually work with any modern C compiler: In particular, both clang and modern gcc verisons silently elide any xor operation with 'junk'. No mergeinfo changes with this commit as r241475 already updated the mergeinfo. Approved by: re (jpaetzel) Notes: svn path=/releng/8.4/; revision=249031
* MFC r246629:Michael Tuexen2013-03-081-7/+7
| | | | | | | Improve code style. No functional change. Notes: svn path=/stable/8/; revision=248020
* MFC r243302:Michael Tuexen2013-03-081-43/+42
| | | | | | | Cleanup the code a bit, which improves the portability. Notes: svn path=/stable/8/; revision=248007
* MFC r243300:Michael Tuexen2013-03-081-1/+0
| | | | | | | Fix the handling of mapped IPv6 addresses in sctp_connectx(). Notes: svn path=/stable/8/; revision=248006
* MFC r242512:Michael Tuexen2013-03-081-1/+3
| | | | | | | Fix errno in a couple of error cases. Notes: svn path=/stable/8/; revision=248000
* MFC r236959:Michael Tuexen2013-03-071-2/+3
| | | | | | | | | | Add a IP_RECVTOS socket option to receive for received UDP/IPv4 packets a cmsg of type IP_RECVTOS which contains the TOS byte. Much like IP_RECVTTL does for TTL. This allows to implement a protocol on top of UDP and implementing ECN. Notes: svn path=/stable/8/; revision=247944
* MFH (r240107,240111,240361): warn against using weak PRNGsDag-Erling Smørgrav2013-02-283-20/+29
| | | | Notes: svn path=/stable/8/; revision=247500
* MFC r246809Niclas Zeising2013-02-282-8/+8
| | | | | | | | | Change examples to be consistent with what style(9) says. Approved by: joel (mentor) Notes: svn path=/stable/8/; revision=247466
* MFH r247014, r247050 and r247051.Giorgos Keramidas2013-02-251-1/+41
| | | | | | | | | | | | | Add a sample program that shows how a custom comparison function and qsort(3) can work together to sort an array of integers. PR: docs/176197 Submitted by: Fernando, fapesteguia at opensistemas.com Christoph Mallon, christoph.mallon at gmx.de Approved by: gjb (mentor), remko (mentor) Notes: svn path=/stable/8/; revision=247276
* MFC r246476:Konstantin Belousov2013-02-211-1/+12
| | | | | | | Document the ERESTART translation to EINTR for devfs nodes. Notes: svn path=/stable/8/; revision=247084
* MFC r243779 (marcel):Xin LI2013-02-051-22/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Protect against DoS attacks, such as being described in CVE-2010-2632. The changes were derived from what has been committed to NetBSD, with modifications. These are: 1. Preserve the existsing GLOB_LIMIT behaviour by including the number of matches to the set of parameters to limit. 2. Change some of the limits to avoid impacting normal use cases: GLOB_LIMIT_STRING - change from 65536 to ARG_MAX so that glob(3) can still provide a full command line of expanded names. GLOB_LIMIT_STAT - change from 128 to 1024 for no other reason than that 128 feels too low (it's not a limit that impacts the behaviour of the test program listed in CVE-2010-2632). GLOB_LIMIT_PATH - change from 1024 to 65536 so that glob(3) can still provide a fill command line of expanded names. 3. Protect against buffer overruns when we hit the GLOB_LIMIT_STAT or GLOB_LIMIT_READDIR limits. We append SEP and EOS to pathend in those cases. Return GLOB_ABORTED instead of GLOB_NOSPACE when we would otherwise overrun the buffer. This change also modifies the existing behaviour of glob(3) in case GLOB_LIMIT is specifies by limiting the *new* matches and not all matches. This is an important distinction when GLOB_APPEND is set or when the caller uses a non-zero gl_offs. Previously pre-existing matches or the value of gl_offs would be counted in the number of matches even though the man page states that glob(3) would return GLOB_NOSPACE when gl_matchc or more matches were found. The limits that cannot be circumvented are GLOB_LIMIT_STRING and GLOB_LIMIT_PATH all others can be crossed by simply calling glob(3) again and with GLOB_APPEND set. The entire description above applies only when GLOB_LIMIT has been specified of course. No limits apply when this flag isn't set! Obtained from: Juniper Networks, Inc Notes: svn path=/stable/8/; revision=246357
* MFC r243758 (marcel):Xin LI2013-02-051-9/+3
| | | | | | | | | | | | | | | | | | | | | | | | | In globextend() when the pathv vector cannot be (re-)allocated, don't free and clear the gl_pathv pointer in the glob_t structure. Such breaks the invariant of the glob_t structure, as stated in the comment right in front of the globextend() function. If gl_pathv was non-NULL, then gl_pathc was > 0. Making gl_pathv a NULL pointer without also setting gl_pathc to 0 is wrong. Since we otherwise don't free the memory associated with a glob_t in error cases, it's unlikely that this change will cause a memory leak that wasn't already there to begin with. Callers of glob(3) must call globfree(3) irrespective of whether glob(3) returned an error or not. MFC r243759 (marcel): In globextend(), take advantage of the fact that realloc(NULL, size) is equivalent to malloc(size). This eliminates the conditional expression used for calling either realloc() or malloc() when realloc() will do all the time. Notes: svn path=/stable/8/; revision=246356
* MFC r244568:Xin LI2013-02-011-8/+4
| | | | | | | | | | | | - Reduce buffer size from LINE_MAX to PATH_MAX, there is no point to store path longer than this. - Fix an unreached case of check against sizeof buf, which in turn leads to an off-by-one nul byte write on the stack. The original condition can never be satisfied because the passed boundary is the maximum value that can be returned, so code was harmless. Notes: svn path=/stable/8/; revision=246198
* MFC r245458:Andrey Zonov2013-01-221-6/+2
| | | | | | | - Use standard RETURN VALUES section. Notes: svn path=/stable/8/; revision=245789
* MFC r245225, r245256: Restrict use of source address selectionHajimu UMEMOTO2013-01-171-2/+8
| | | | | | | of getipnodebyname(1) only to IPv6 address. Notes: svn path=/stable/8/; revision=245557
* MFC 244756 + 244757:Xin LI2013-01-114-0/+892
| | | | | | | Add Simplified Chinese catalogs. Notes: svn path=/stable/8/; revision=245278
* MFC r242460: fopen(3): Mention that the "x" mode option is from C11.Jilles Tjoelker2012-11-081-1/+5
| | | | Notes: svn path=/stable/8/; revision=242773
* MFC r242429: fcntl(2): Fix typos in name of constant "F_DUP2FD_CLOEXEC".Jilles Tjoelker2012-11-081-2/+2
| | | | Notes: svn path=/stable/8/; revision=242770
* MFC r241844:Eitan Adler2012-11-041-1/+1
| | | | | | | | | remove duplicate semicolons where possible. Approved by: cperciva (implicit) Notes: svn path=/stable/8/; revision=242543
* MFC r241855:Eitan Adler2012-10-292-16/+20
| | | | | | | | | | Update the kill(2) and killpg(2) man pages to the modern permission checks. Also indicate killpg(2) is POSIX compliant. Approved by: cperciva (implicit) Notes: svn path=/stable/8/; revision=242297
* MFC r241373:Eitan Adler2012-10-121-2/+1
| | | | | | | | | | | | | | | Remove undefined behavior from sranddev() and srandomdev(). This doesn't actually work with any modern C compiler: In particular, both clang and modern gcc verisons silently elide any xor operation with 'junk'. Approved by: cperciva (implicit) Notes: svn path=/stable/8/; revision=241475
* MFC 240132:John Baldwin2012-10-071-1/+1
| | | | | | | | When WIFCONTINUED was added, the number of "first" macros grew from three to four. Notes: svn path=/stable/8/; revision=241317
* MFC r241062:Eitan Adler2012-10-041-5/+4
| | | | | | | | | clarify the wording for 'first' and 'last' Approved by: cperciva (implicit) Notes: svn path=/stable/8/; revision=241172
* MFC r241007, r241008:Pedro F. Giffuni2012-09-308-41/+19
| | | | | | | | | | | | Complete revert of r239963 (from head). The attempt to merge changes from the linux libtirpc caused rpc.lockd to exit after startup under unclear conditions. Reported by: David Wolfskill Notes: svn path=/stable/8/; revision=241060
* MFC 240880:Pedro F. Giffuni2012-09-271-4/+0
| | | | | | | | | | | | | Revert a change from Bull's NFSv4 libtirpc implementation: libtirpc: be sure to free cl_netid and cl_tp This change is causing rpc.lockd to exit after startup. Reported by: David Wolfskill Notes: svn path=/stable/8/; revision=240980
* MFC r239963:Pedro F. Giffuni2012-09-229-19/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bring some changes from Bull's NFSv4 libtirpc implementation. ____ Fixed infinite loop in svc_run() ____ __rpc_taddr2uaddr_af() assumes the netbuf to always have a non-zero data. This is a bad assumption and can lead to a seg-fault. This patch adds a check for zero length and returns NULL when found. ____ Changed clnt_spcreateerror() to return clearer and more concise error messages. ____ Converted all uid and gid variables of the type uid_t and gid_t. ____ libtirpc: set r_netid and r_owner in __rpcb_findaddr_timed These fields in the rpcbind GETADDR call are being passed uninitialized to CLNT_CALL. In the case of x86_64 at least, this usually leads to a segfault. On x86, it sometimes causes segfaults and other times causes garbage to be sent on the wire. rpcbind generally ignores the r_owner field for calls that come in over the wire, so it really doesn't matter what we send in that slot. We just need to send something. The reference implementation from Sun seems to send a blank string. Have ours follow suit. ____ libtirpc: be sure to free cl_netid and cl_tp When creating a client with clnt_tli_create, it uses strdup to copy strings for these fields if nconf is passed in. clnt_dg_destroy frees these strings already. Make sure clnt_vc_destroy frees them in the same way. ____ Obtained from: Bull GNU/Linux NFSv4 Project Notes: svn path=/stable/8/; revision=240800
* MFC r238835:Konstantin Belousov2012-08-291-4/+14
| | | | | | | Document F_DUP2FD_CLOEXEC. Notes: svn path=/stable/8/; revision=239863
* MFC r238615:Konstantin Belousov2012-08-291-4/+15
| | | | | | | Document F_DUPFD_CLOEXEC. Notes: svn path=/stable/8/; revision=239862
* MFC 230782,237274:John Baldwin2012-08-281-5/+4
| | | | | | | | | | | | | | | Refine the implementation of POSIX_FADV_NOREUSE to perform POSIX_FADV_DONTNEED requests on the currently accessed portion of the file on each read(2) or write(2) rather than using direct I/O. This gives much better performance including read-ahead and write clustering similar to normal read(2) and write(2) calls. If subsequent read(2) and write(2) calls are sequential, then the POSIX_FADV_DONTNEED requests will cover the entire sequentially-accessed range. Notes: svn path=/stable/8/; revision=239788
* MFC r238853: Correct BUGS description of static buffer useEd Maste2012-08-201-3/+3
| | | | | | | | Since r142667 strerror has unconditionally returned a pointer to a static buffer. Notes: svn path=/stable/8/; revision=239424
* MFC r238328:David Xu2012-07-171-1/+1
| | | | | | | | Executing CPUID with EAX set to 1 to actually get feature flags. PR: 169730 Notes: svn path=/stable/8/; revision=238541
* MFC r237286, r237523:Eitan Adler2012-06-271-2/+4
| | | | | | | | | | Don't close an uninitialized descriptor. PR: bin/167302 Approved by: cperciva (implicit) Notes: svn path=/stable/8/; revision=237634
* MFC r225808:Warren Block2012-06-251-3/+3
| | | | | | | | | | | Fix grammar. PR: 140457 Submitted by: jeremyhu AT apple.com Approved by: gjb (mentor) Notes: svn path=/stable/8/; revision=237585
* MFC r237061:Konstantin Belousov2012-06-211-1/+11
| | | | | | | | | Make sure that fstab fd is not leaked on exec. PR: kern/169023 Notes: svn path=/stable/8/; revision=237362
* MFC r230188i (by das):Alexander Motin2012-06-131-1/+2
| | | | | | | | | Correct some bugs that resulted from arm/_fpmath.h being blindly copied from the x86 version, which has a completely different long double format. Notes: svn path=/stable/8/; revision=237024
* MFC 230260-230262,230269,230270,230426,230429,230538,230765,230766,230864,John Baldwin2012-06-1317-10/+624
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 232520 (partial),235563: Add support for the extended FPU states on amd64, both for native 64bit and 32bit ABIs. As a side-effect, it enables AVX on capable CPUs. In particular: - Query the CPU support for XSAVE, list of the supported extensions and the required size of FPU save area. The hw.use_xsave tunable is provided for disabling XSAVE, and hw.xsave_mask may be used to select the enabled extensions. - Remove the FPU save area from PCB and dynamically allocate the (run-time sized) user save area on the top of the kernel stack, right above the PCB. Reorganize the thread0 PCB initialization to postpone it after BSP is queried for save area size. - The dumppcb, stoppcbs and susppcbs now do not carry the FPU state as well. FPU state is only useful for suspend, where it is saved in dynamically allocated suspfpusave area. - Use XSAVE and XRSTOR to save/restore FPU state, if supported and enabled. - Define new mcontext_t flag _MC_HASFPXSTATE, indicating that mcontext_t has a valid pointer to out-of-struct extended FPU state. Signal handlers are supplied with stack-allocated fpu state. The sigreturn(2) and setcontext(2) syscall honour the flag, allowing the signal handlers to inspect and manipilate extended state in the interrupted context. - The getcontext(2) never returns extended state, since there is no place in the fixed-sized mcontext_t to place variable-sized save area. And, since mcontext_t is embedded into ucontext_t, makes it impossible to fix in a reasonable way. Provide a sysarch(2) facility to query extended FPU state. - Add API for obtaining extended machine context states that cannot be fit into existing mcontext_t. On i386 and amd64 return the extended FPU states using getcontextx(3). For other architectures, getcontextx(3) returns the same information as getcontext(2). - Add ptrace(2) support for getting and setting extended state; while there, implement missed PT_I386_{GET,SET}XMMREGS for 32bit binaries. - Change fpu_kern KPI to not expose struct fpu_kern_ctx layout to consumers, making it opaque. Internally, struct fpu_kern_ctx now contains a space for the extended state. Convert in-kernel consumers of fpu_kern KPI both on i386 and amd64. Reviewed by: kib Notes: svn path=/stable/8/; revision=237009
* MFC r236288:Eitan Adler2012-06-131-1/+1
| | | | | | | | | | Only set _w to 0 when the file stream is not currently reading. Without this fflush may fail to write data in the buffer. PR: kern/137819 Approved by: cperciva (implicit) Notes: svn path=/stable/8/; revision=236982
* MFC r236042:Konstantin Belousov2012-05-291-4/+4
| | | | | | | Clarify the SEEK_HOLE description, it repositions the file pointer. Notes: svn path=/stable/8/; revision=236225
* MFC r235140:Glen Barber2012-05-1812-14/+17
| | | | | | | | | General mdoc(7) and typo fixes. PR: 167713 Notes: svn path=/stable/8/; revision=235581
* MFC r235286:Glen Barber2012-05-188-11/+12
| | | | | | | | | General mdoc(7) and typo fixes. PR: 167734 Notes: svn path=/stable/8/; revision=235576
* MFC r235143:Konstantin Belousov2012-05-151-2/+5
| | | | | | | Plug a leak. Notes: svn path=/stable/8/; revision=235468
* MFC r211706:Konstantin Belousov2012-05-095-4/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | On shared object unload, in __cxa_finalize, call and clear all installed atexit and __cxa_atexit handlers that are either installed by unloaded dso, or points to the functions provided by the dso. Use _rtld_addr_phdr to locate segment information from the address of private variable belonging to the dso, supplied by crtstuff.c. Provide utility function __elf_phdr_match_addr to do the match of address against dso executable segment. Call back into libthr from __cxa_finalize using weak __pthread_cxa_finalize symbol to remove any atfork handler which function points into unloaded object. The rtld needs private __pthread_cxa_finalize symbol to not require resolution of the weak undefined symbol at initialization time. This cannot work, since rtld is relocated before sym_zero is set up. MFC r211894: Do not call __pthread_cxa_finalize with invalid struct dl_phdr_info. Requested and tested by: Peter Jeremy <peter rulingia com> Notes: svn path=/stable/8/; revision=235198
* MFC r211705:Konstantin Belousov2012-05-092-0/+9
| | | | | | | | | | | Introduce implementation-private rtld interface _rtld_addr_phdr, which fills struct dl_phdr_info for the shared object that contains the specified address, if any. Requested and tested by: Peter Jeremy <peter rulingia com> Notes: svn path=/stable/8/; revision=235191
* MFC r234997:Michael Tuexen2012-05-091-1/+0
| | | | | | | Remove debug output. Notes: svn path=/stable/8/; revision=235185
* MFC r234772:Jeremie Le Hen2012-05-081-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Import stdbuf(1) and the shared library it relies on. This tool changes the default buffering behaviour of standard stdio streams. It only works on dynamic binaries. To make it work for static ones it would require cluttering stdio because there no single entry point. PR: 166660 Reviewed by: current@, jhb Approved by: kib (mentor) MFC after: 1 week MFC r234773: Fix small documentation mistakes. Submitted by: brueffer Approved by: kib (mentor) MFC r234779: Use standard getopt(3) error message. Submitted by: jilles Approved by: kib (mentor) Notes: svn path=/stable/8/; revision=235141
* MFC r234820:Eitan Adler2012-05-061-0/+2
| | | | | | | | | | pread(2) might fail with EBUSY, so document it PR: docs/167201 Approved by: cperciva (implicit) Notes: svn path=/stable/8/; revision=235089
* MFC r234819:Eitan Adler2012-05-062-1/+12
| | | | | | | | | | Allow users of gprof to get per run output files (using the pid) PR: bin/99800 Approved by: cperciva (implicit) Notes: svn path=/stable/8/; revision=235084
* MFC r234769:Konstantin Belousov2012-05-052-2/+22
| | | | | | | Fix several memory and lock leaks on the out of memory condition. Notes: svn path=/stable/8/; revision=235046
* MFC r234131:Eitan Adler2012-05-032-7/+12
| | | | | | | | | | | Return EBADF instead of EMFILE from dup2 when the second argument is outside the range of valid file descriptors PR: kern/164970 Approved by: cperciva (implicit) Notes: svn path=/stable/8/; revision=234967
* MFC r234714, r234700:Eitan Adler2012-05-031-1/+13
| | | | | | | | | | Document the standardization status of err* and warn* PR: docs/164939 Approved by: cperciva (implicit) Notes: svn path=/stable/8/; revision=234964