summaryrefslogtreecommitdiffstats
path: root/lib/libc
Commit message (Collapse)AuthorAgeFilesLines
* libc/locale: Fix type breakage in __collate_range_cmp().pfg2016-06-055-11/+25
| | | | | | | | | | | | | | | | When collation support was brought in, the second and third arguments in __collate_range_cmp() were changed from int to wchar_t, breaking the ABI. Change them to a "char" type which makes more sense and keeps the ABI compatible. Also introduce __wcollate_range_cmp() which does work with wide characters. This function is used only internally in libc so we don't export it. Use the new function in glob(3), fnmatch(3), and regexec(3). PR: 179721 Suggested by: ache. jilles MFC after: 3 weeks (perhaps partial only)
* Reflect error indication according to POSIX and what those functionsache2016-06-051-2/+2
| | | | currently do.
* Fix markup.kib2016-06-041-1/+1
| | | | Sponsored by: The FreeBSD Foundation
* Improve errno documentation in pthread_create(3) and thr_new(2)vangyzen2016-06-032-4/+11
| | | | | | | | | | Add some missing errno values to thr_new(2) and pthread_create(3). In particular, EDEADLK was not documented in the latter. While I'm here, improve some English and cross-references. Reviewed by: kib Sponsored by: Dell Inc. Differential Revision: https://reviews.freebsd.org/D6663
* citrus: Remove redundant code in _citrus_esdb_get_list().pfg2016-06-021-12/+6
| | | | | | | | It appears "sorted" may have not been implemented. Sorted or not, we always follow the same action so simplify the code. Leave a note for future generations. CID: 1347084
* thr_*(2): Add xrefs to what libthr implements using each syscall.jilles2016-06-015-8/+29
| | | | | | | | | | | Add text to thr_exit(2) and thr_new(2) discouraging their use in applications since calling these in a process with libthr loaded will confuse libthr and is likely to cause hangs or crashes. The thr_kill2(2) call is not used by libthr and may be useful in special applications. The other calls can be used in applications but it should not be necessary.
* Document behavior of wait introduced in the r286698.oshogbo2016-06-011-1/+9
| | | | | | Suggested by: glebius Reviewed by: wblock, bjk Differential Revision: https://reviews.freebsd.org/D6080
* Don't use fixup for C99 and up, the compiler result is already correct.ache2016-06-014-0/+8
| | | | | | Suggested by: bde MFC after: 1 week
* For EILSEQ case in mbsnrtowcs() and wcsnrtombs() update src to point toache2016-05-312-0/+3
| | | | | | | | the character after the one this conversion stopped at. PR: 209907 Submitted by: Roel Standaert <roel@abittechnical.com> (partially) MFC after: 3 days
* Fix prototype of dbm_open().ed2016-05-312-2/+2
| | | | | | | | The last argument of dbm_open() should be a mode_t according to POSIX; not an int. Reviewed by: pfg, kib Differential Revision: https://reviews.freebsd.org/D6650
* Let dbm's datum::dptr use the right type.ed2016-05-301-2/+2
| | | | | | | | | According to POSIX, it should use void *, not char *. Unfortunately, the dsize field also has the wrong type. It should be size_t. I'm not going to change that, as that will break the ABI. Reviewed by: pfg Differential Revision: https://reviews.freebsd.org/D6647
* Fix the signature of the psignal() function.ed2016-05-302-4/+4
| | | | | | | | POSIX 2008 added the psignal() function which has already been part of the BSDs for a long time. The only difference is, the POSIX version uses an 'int' for the signal number, unlike our version which uses an 'unsigned int'. Fix up the function to use an 'int'. This should not affect the ABI.
* Mark jail(2), and the sysctls that it (and only it) uses as deprecated.jamie2016-05-301-1/+1
| | | | jail(8) has long used jail_set(2), and those sysctl only cause confusion.
* Micro optimize: C standard guarantees that right shift for unsigned valueache2016-05-291-1/+1
| | | | | | | fills left bits with zero, and we have exact 32bit unsigned value (uint32_t), so there is no reason to add "& 0x7fffffff" here. MFC after: 1 week
* _umtx_op(2): Note deprecation of UMTX_OP_MUTEX_WAKE.jilles2016-05-291-1/+15
|
* _umtx_op(2),thr_*(2): Various spelling, grammar and mdoc fixes.jilles2016-05-296-60/+73
|
* 1) Unifdef USE_WEAK_SEEDING since it is too obsolete to support and makesache2016-05-291-41/+11
| | | | | | | | | | | | | reading hard. 2) Instead of doing range transformation in each and every function here, do it single time directly in do_rand(). One "mod" operation overhead is not a big deal, but the code looks nicer and possible future functions additions or PRNG change do not miss range transformations neither have unneeded ones. 3) Use POSIX argument types for visible functions (cosmetic). MFC after: 1 week
* 1) Unifdef USE_WEAK_SEEDING it is too obsolete to support and makes readingache2016-05-291-46/+14
| | | | | | | | | | | | | harder. 2) ACM paper require seed to be in [1, 2^31-2] range, so use the same range shifting as already done for rand(3). Also protect srandomdev() + TYPE_0 case (non default) from negative seeds. 3) Don't check for valid "type" range in setstate(), it is always valid as calculated. Instead add a check that rear pointer not exceeed end pointer. MFC after: 1 week
* Let l64a() properly null terminate its result.ed2016-05-261-22/+14
| | | | | | | | | | | | | | Though the buffer used by l64a() is initialized with null bytes, repetetive calls may end up having trailing garbage of previous invocations because we don't end up terminating the string. Instead of importing NetBSD's fix, use this opportunity to simplify this function dramatically, for example by just storing the Base64 character set in a string. There is also no need to do the bitmasking, as we can just use the proper integer type from <stdint.h>. MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D6511
* Do not generate code for sbrk syscall -- sbrk support was removed.br2016-05-251-0/+1
| | | | Pointed out by: andrew
* libc: regexec(3) adjustment.pfg2016-05-252-24/+50
| | | | | | | | | | | | | | | | | | | | | | Change the behavior of when REG_STARTEND is combined with REG_NOTBOL. From the original posting[1]: "Enable the assumption that pmatch[0].rm_so is a continuation offset to a string and allows us to do a proper assessment of the character in regards to it's word position ('^' or '\<'), without risking going into unallocated memory." This change makes us similar to how glibc handles REG_STARTEND | REG_NOTBOL, and is closely related to a soon-to-land fix to sed. Special thanks to Martijn van Duren and Ingo Schwarze for working out some consistent behaviour. Differential Revision: https://reviews.freebsd.org/D6257 Taken from: openbsd-tech 2016-05-24 [1] (Martijn van Duren) Relnotes: yes MFC after: 1 month
* Remove legacy brk and sbrk from RISC-V.br2016-05-254-161/+1
| | | | | | Discussed with: andrew Sponsored by: DARPA, AFRL Sponsored by: HEIF5
* Fix Coverity CID 1016714 Resource leak in process_file_actions_entry()truckman2016-05-251-3/+6
| | | | | | | | Don't leak a file descriptor of _dup2() fails (shouldn't happen). Reported by: Coverity CID: 1016714 MFC after: 1 week
* Fix 1016718 Resource leak.truckman2016-05-251-1/+3
| | | | | | | | Don't leak a file descriptor if fchdir() fails. Reported by: Coverity CID: 1016718 MFC after: 1 week
* Fix up r300385ngie2016-05-241-2/+3
| | | | | | | | | | | | | | I accidentally glossed over the fact that tmp is manipulated via strchr, so if we tried to free `tmp` after r300385, it would have crashed. Create a separate pointer (tmp2) to track the original allocation of `tmp`, and free `tmp2` if `p->nc_lookups` can't be malloced MFC after: 4 days X-MFC with: r300385 Reported by: Coverity CID: 1356026 Sponsored by: EMC / Isilon Storage Division
* Remove redundant NULLing of outbuf_pmapngie2016-05-241-1/+0
| | | | | | | | | If reallocf ever failed, outbuf_pmap would already be NULL MFC after: 1 week X-MFC with: r300620 Reported by: cem Sponsored by: EMC / Isilon Storage Division
* Use reallocf instead of malloc to fix leak with outbuf_pmapngie2016-05-241-1/+3
| | | | | | | | | | | | | | | | The previous code overwrote outbuf_pmap's memory with malloc once per loop iteration, which leaked its memory; use reallocf instead to ensure that memory is properly free'd each loop iteration. Add a outbuf_pmap = NULL in the failure case to avoid a double-free at the bottom of the function. Differential Revision: https://reviews.freebsd.org/D6495 MFC after: 1 week Reported by: Coverity CID: 1038776 Reviewed by: markj, pfgj Sponsored by: EMC / Isilon Storage Division
* vfork(2): Mention some risks of calling vfork() from application code.jilles2016-05-221-12/+28
| | | | MFC after: 1 week
* 1) POSIX prohibits printing errors to stderr here and requireache2016-05-221-15/+10
| | | | | | | | | | | | | | | returning NULL: "Upon successful completion, initstate() and setstate() shall return a pointer to the previous state array; otherwise, a null pointer shall be returned. Although some implementations of random() have written messages to standard error, such implementations do not conform to POSIX.1-2008." 2) Move error detections earlier to prevent state modifying. MFC after: 1 week
* nis_rpcent: don't leak resultbuf from yp_first(..)/yp_next(..)ngie2016-05-221-0/+2
| | | | | | | | | | If the buffer couldn't be adequately resized to accomodate an additional "\n", it would leak resultbuf by breaking from the loop early MFC after: 2 weeks Reported by: Coverity CID: 1016702 Sponsored by: EMC / Isilon Storage Division
* Call endnetconfig on nc_handle sooner to avoid leaking nc_handle if tmpnconfngie2016-05-221-1/+1
| | | | | | | | | | | | was NULL This would theoretically happen if the netconfig protocol family and protocol semantics were never matched. MFC after: 2 weeks Reported by: Coverity CID: 978179 Sponsored by: EMC / Isilon Storage Division
* getnetid(..): consistently fclose fd at the end of the functionngie2016-05-221-11/+15
| | | | | | | | This mutes a false positive with cppcheck, but also helps eliminate future potential issues with this variable MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Division
* Don't leak `handle` if svc_tp_create(..) succeeds and allocating a newngie2016-05-221-1/+3
| | | | | | | | | struct xlist object fails MFC after: 1 week Reported by: Coverity CID: 978277 Sponsored by: EMC / Isilon Storage Division
* Don't leak `tmp` if `p->nc_lookups` can't be mallocedngie2016-05-221-0/+1
| | | | | | MFC after: 1 week Reported by: cppcheck Sponsored by: EMC / Isilon Storage Division
* libc/regex: fix two buffer underruns.pfg2016-05-211-9/+6
| | | | | | | | | | | | Fix some rather complex regex issues found on OpenBSD as part of some ongoing work to fix a sed(1) bug. Curiously the OpenBSD tests don't trigger segfaults on FreeBSD but the bugs were confirmed by running a port of FreeBSD's regex under OpenBSD's malloc. Huge thanks to Ingo for confirming the behavior. Taken from: Ingo Schwarze (through openbsd-tech 2016-05-15) MFC after: 1 week
* FTS: Remove stale reference to nfs4 fs which was removed in r192578.bdrewery2016-05-212-2/+0
| | | | MFC after: 2 weeks
* Remove brk and sbrk from arm64. They were defined in The Single UNIXandrew2016-05-204-155/+2
| | | | | | | | | | | | | | | | | | | | | Specification, Version 2, but marked as legacy, and have been removed from later specifications. After 12 years it is time to remove them from new architectures when the main use for sbrk is an invalid method to attempt to find how much memory has been allocated from malloc. There are a few places in the tree that still call sbrk, however they are not used on arm64. They will need to be fixed to cross build from arm64, but these will be fixed in a follow up commit. Old copies of binutils from ports called into sbrk, however this has been fixed around 6 weeks ago. It is advised to update binutils on arm64 before installing a world that includes this change. Reviewed by: brooks, emaste Obtained from: brooks Relnotes: yes Sponsored by: ABT Systems Ltd Differential Revision: https://reviews.freebsd.org/D6464
* Document _umtx_op(2) interface for the implementation of robust mutexes.kib2016-05-191-12/+183
| | | | | | | | In libthr(3), list added knobs. Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D6427
* Make armv6 hard float abi by default. Kill armv6hf.imp2016-05-184-5/+7
| | | | | | | Allow CPUTYPE=soft to build the current soft-float abi libraries. Add UPDATING entry to announce this. Approved by: re@ (gjb)
* Add implementation of robust mutexes, hopefully close enough to thekib2016-05-173-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | intention of the POSIX IEEE Std 1003.1TM-2008/Cor 1-2013. A robust mutex is guaranteed to be cleared by the system upon either thread or process owner termination while the mutex is held. The next mutex locker is then notified about inconsistent mutex state and can execute (or abandon) corrective actions. The patch mostly consists of small changes here and there, adding neccessary checks for the inconsistent and abandoned conditions into existing paths. Additionally, the thread exit handler was extended to iterate over the userspace-maintained list of owned robust mutexes, unlocking and marking as terminated each of them. The list of owned robust mutexes cannot be maintained atomically synchronous with the mutex lock state (it is possible in kernel, but is too expensive). Instead, for the duration of lock or unlock operation, the current mutex is remembered in a special slot that is also checked by the kernel at thread termination. Kernel must be aware about the per-thread location of the heads of robust mutex lists and the current active mutex slot. When a thread touches a robust mutex for the first time, a new umtx op syscall is issued which informs about location of lists heads. The umtx sleep queues for PP and PI mutexes are split between non-robust and robust. Somewhat unrelated changes in the patch: 1. Style. 2. The fix for proper tdfind() call use in umtxq_sleep_pi() for shared pi mutexes. 3. Removal of the userspace struct pthread_mutex m_owner field. 4. The sysctl kern.ipc.umtx_vnode_persistent is added, which controls the lifetime of the shared mutex associated with a vnode' page. Reviewed by: jilles (previous version, supposedly the objection was fixed) Discussed with: brooks, Martin Simmons <martin@lispworks.com> (some aspects) Tested by: pho Sponsored by: The FreeBSD Foundation
* Don't call free_addrselectpolicy(&policyhead) before policyhead has beentruckman2016-05-161-1/+0
| | | | | | | initialized. Reported by: Coverity CID: 1018727
* Since rdata is only used as an argument to the immediately followingtruckman2016-05-161-5/+3
| | | | | | | | | call to res_nopt_rdata(), revert r299879 and fix CID 603941 by moving rdata = &buf[n]; inside the if block. Reported by: Coverity CID: 603941
* Likely a false positive ... but make sure that -1 can't be used as antruckman2016-05-161-4/+6
| | | | | | | | array index by splitting up a test. Reported by: Coverity CID: 603941 MFC after: 1 week
* Add thr*.2 and _umtx_op.2 manpages to the build.kib2016-05-141-1/+8
| | | | Sponsored by: The FreeBSD Foundation
* Document the non-obsoleted kernel interfaces used by libthr.kib2016-05-146-0/+1858
| | | | | | Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D6335
* iconvctl(3): remove superfluous NULL pointer testsvangyzen2016-05-144-6/+83
| | | | | | | | | | | | | | | convname and dst are guaranteed to be non-NULL by iconv_open(3). src is an array. Remove these tests for NULL pointers. While I'm here, eliminate a strlcpy with a correct but suspicious-looking calculation for the third parameter (i.e. not a simple sizeof). Compare the strings in-place instead of copying. Found by: bdrewery Found by: Coverity CID: 1130050, 1130056 MFC after: 3 days Sponsored by: Dell Inc. Differential Revision: https://reviews.freebsd.org/D6338
* Read the contents of the snapshot files properlyngie2016-05-131-18/+15
| | | | | | | | | | - Use fgetln instead of fgets; localize complexity related to fgetln(3) inside the loop. - Skip over blank lines. - Skip over lines (properly) that start with a "#" MFC after: 1 week Sponsored by: EMC / Isilon Storage Division
* Update jemalloc to 4.2.0.jasone2016-05-131-1/+1
|
* libc: Actually export fopencookie(3)cem2016-05-121-0/+1
| | | | | | A follow-up to r299456. Sponsored by: EMC / Isilon Storage Division
* print_positional_test: Fix misuse of wchar APIscem2016-05-121-3/+4
| | | | | | | | These APIs take unit length, not byte length parameters. Reported by: Coverity CIDs: 1338543, 1338544, 1338545 Sponsored by: EMC / Isilon Storage Division
OpenPOWER on IntegriCloud