summaryrefslogtreecommitdiffstats
path: root/lib/libc
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* nss/gethostby_test: fix broken vector iteration of gethostbyaddr h_aliasescem2016-05-121-1/+1
| | | | | | | | | h_aliases is a NULL-terminated rather than fixed-length array. nitems() is not a valid way to determine its end; instead, check for NULL. Reported by: Coverity CID: 1346578 Sponsored by: EMC / Isilon Storage Division
* libc: Add fopencookie(3) wrapper around funopen(3)cem2016-05-114-3/+329
| | | | | | Reviewed by: jhb, oshogbo Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D6282
* Rename dprintf into dbg_printf to avoid collision with dprintf(3)bapt2016-05-101-10/+10
| | | | | When dprintf(3) in 2009 was added a _WITH_DPRINTF guard has also been added. This rename is made in preparation for the removal of this guard
* libc/xdr: unsign some loop indexes.pfg2016-05-061-2/+2
| | | | | | Although usually small, values produced by nitems() are unsigned. Unsign inxdeing variables related to nitems() macros to avoid signed vs. unsigned comparisons.
* Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installedngie2016-05-0427-149/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | after r298107 Summary of changes: - Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that namespacing is kept with FILES appropriately, and that this shouldn't need to be repeated if the namespace changes -- only the definition of PACKAGE needs to be changed - Allow PACKAGE to be overridden by callers instead of forcing it to always be `tests`. In the event we get to the point where things can be split up enough in the base system, it would make more sense to group the tests with the blocks they're a part of, e.g. byacc with byacc-tests, etc - Remove PACKAGE definitions where possible, i.e. where FILES wasn't used previously. - Remove unnecessary TESTSPACKAGE definitions; this has been elided into bsd.tests.mk - Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES; ${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk. - Fix installation of files under data/ subdirectories in lib/libc/tests/hash and lib/libc/tests/net/getaddrinfo - Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup) Document the proposed changes in share/examples/tests/tests/... via examples so it's clear that ${PACKAGES}FILES is the suggested way forward in terms of replacing FILES. share/mk/bsd.README didn't seem like the appropriate method of communicating that info. MFC after: never probably X-MFC with: r298107 PR: 209114 Relnotes: yes Tested with: buildworld, installworld, checkworld; buildworld, packageworld Sponsored by: EMC / Isilon Storage Division
* Correct wording.kib2016-05-031-1/+1
| | | | | Submitted by: David A. Bright MFC after: 2 weeks
* Add EVFILT_VNODE open, read and close notifications.kib2016-05-031-8/+26
| | | | | | | While there, order EVFILT_VNODE notes descriptions alphabetically. Based on submission, and tested by: Vladimir Kondratyev <wulf@cicgroup.ru> MFC after: 2 weeks
* Issue NOTE_EXTEND when a directory entry is added to or removed fromkib2016-05-021-2/+8
| | | | | | | | the monitored directory as the result of rename(2) operation. The renames staying in the directory are not reported. Submitted by: Vladimir Kondratyev <wulf@cicgroup.ru> MFC after: 2 weeks
* As a reader service, explain NOTE_LINK reporting for the directories.kib2016-05-011-0/+4
| | | | | Submitted by: Vladimir Kondratyev <wulf@cicgroup.ru> MFC after: 1 week
* Provide an example to the kqueue man page, showingbcr2016-05-011-1/+52
| | | | | | | | | | | | | a basic usage example. Although it is an untypical example for the use of kqueue, it is better than nothing and should get people started. PR: 196844 Submitted by: fernando.apesteguia@gmail.com Reviewed by: kib Approved by: kib MFC after: 5 days Differential Revision: https://reviews.freebsd.org/D6082
* libc: spelling fixes.pfg2016-04-3034-43/+43
| | | | Mostly on comments.
* libc: make more use of the howmany() macro when available.pfg2016-04-262-3/+2
| | | | | We have a howmany() macro in the <sys/param.h> header that is convenient to re-use as it makes things easier to read.
* regex: prevent two improbable signed integer overflows.pfg2016-04-231-2/+2
| | | | | | | | | | | In matcher() we used an integer to index nsub of type size_t. In print() we used an integer to index nstates of type sopno, typedef'd long. In both cases the indexes never take negative values. Match the types to avoid any error. MFC after: 5 days
* Restore the original ascii.c from prior to r290494bapt2016-04-211-13/+10
| | | | | | | | It was doing the right thing, there was no need to "fail" to reinvent it from none.c Pointy hat: bapt Submitted by: ache
* Check the returned value of memchr(3) before using itbapt2016-04-201-1/+4
| | | | | Reported by: Coverity CID: 1338530
* Minor indentation issue.pfg2016-04-201-2/+1
|
* libc: use our roundup2/rounddown2() macros when param.h is available.pfg2016-04-203-6/+6
| | | | | rounddown2 tends to produce longer lines than the original code but still it makes the code more readable.
* Fix double fclose of `fp1` when freopen failsngie2016-04-201-1/+0
| | | | | | | | | | | | freopen handles closing file descriptors on error, with the exception of fdopen'ed descriptors, so closing an already fclose'd file descriptor is incorrect CID: 1338525 Differential Revision: https://reviews.freebsd.org/D6013 MFC after: 2 weeks Reported by: Coverity Sponsored by: EMC / Isilon Storage Division
* Make sure fmemopen succeeds in :test_append_binary_pos before calling ftellngie2016-04-191-0/+2
| | | | | | | | | | | on the FILE object This fixes potential null pointer dereferences on failure CID: 1254952 MFC after: 2 weeks Reported by: Coverity Sponsored by: EMC / Isilon Storage Division
* Remove trailing whitespace and use `nitems(mib)` instead of `2` whenngie2016-04-191-2/+2
| | | | | | | calling sysctl(3) MFC after: 3 days Sponsored by: EMC / Isilon Storage Division
* libc: do not include <sys/types.h> where <sys/param.h> was already includedavos2016-04-1839-42/+3
| | | | | | According to style(9): > normally, include <sys/types.h> OR <sys/param.h>, but not both. (<sys/param.h> already includes <sys/types.h> when LOCORE is not defined).
* Re-use our roundup2() macro instead of reinventing the wheel.pfg2016-04-181-6/+4
| | | | Obtained from: DragonflyBSD
* Fixed indentation, minor style.pluknet2016-04-181-12/+12
|
* Fix markup on "\n" in printf so it renders correctly.wblock2016-04-171-4/+4
| | | | | | PR: 208852 Submitted by: coder@tuxfamily.org MFC after: 1 week
* libc: make some more use of the nitems() macro.pfg2016-04-1610-26/+22
| | | | | | | | We have an nitems() macro in the <sys/param.h> header that is convenient to re-use as it makes things easier to read. Given that it is available already without adding additional headers and other parts of libc already use it, extend a bit more its use.
* MFHgjb2016-04-163-0/+3
|\ | | | | | | Sponsored by: The FreeBSD Foundation
OpenPOWER on IntegriCloud