summaryrefslogtreecommitdiffstats
path: root/lib/libc
Commit message (Collapse)AuthorAgeFilesLines
* MFC r299502:ngie2016-06-101-1/+1
| | | | | | | | | | | r299502 (by cem): nss/gethostby_test: fix broken vector iteration of gethostbyaddr h_aliases 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. CID: 1346578
* MFC r300624:ngie2016-06-081-2/+3
| | | | | | | | | | | | Fix up r300385 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 CID: 1356026
* MFC r300385:ngie2016-06-081-0/+1
| | | | Don't leak `tmp` if `p->nc_lookups` can't be malloced
* MFC r300386:ngie2016-06-081-1/+3
| | | | | | | Don't leak `handle` if svc_tp_create(..) succeeds and allocating a new struct xlist object fails CID: 978277
* MFC r300387,r300388,r300389:ngie2016-06-083-12/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | r300387: getnetid(..): consistently fclose fd at the end of the function This mutes a false positive with cppcheck, but also helps eliminate future potential issues with this variable r300388: Call endnetconfig on nc_handle sooner to avoid leaking nc_handle if tmpnconf was NULL This would theoretically happen if the netconfig protocol family and protocol semantics were never matched. CID: 978179 r300389: nis_rpcent: don't leak resultbuf from yp_first(..)/yp_next(..) If the buffer couldn't be adequately resized to accomodate an additional "\n", it would leak resultbuf by breaking from the loop early CID: 1016702
* MFC r300620,r300621:ngie2016-06-081-1/+2
| | | | | | | | | | | | | | | | | | | | | r300620: Use reallocf instead of malloc to fix leak with outbuf_pmap 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. CID: 1038776 r300621: Remove redundant NULLing of outbuf_pmap If reallocf ever failed, outbuf_pmap would already be NULL
* MFC: r301115ache2016-06-054-0/+8
| | | | | | Don't use fixup for C99 and up, the compiler result is already correct. Suggested by: bde
* MFC: r301448ache2016-06-051-2/+2
| | | | | Reflect error indication according to POSIX and what those functions currently do.
* MFC: r300956ache2016-06-051-41/+11
| | | | | | | | | | | | 1) Unifdef USE_WEAK_SEEDING since it is too obsolete to support and makes 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).
* Prepare for merge of r300956. One year old r288030 which fix prototypesache2016-06-051-4/+3
| | | | | can't be merged without conflicts and require merging of other versions too and I don't want to go deep in that unmerged commits chain.
* MFC: r300953ache2016-06-051-47/+15
| | | | | | | | | | | | | | | | | | 1) Unifdef USE_WEAK_SEEDING it is too obsolete to support and makes reading 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: r300965 Micro optimize: C standard guarantees that right shift for unsigned value fills left bits with zero, and we have exact 32bit unsigned value (uint32_t), so there is no reason to add "& 0x7fffffff" here.
* MFC r300341:bdrewery2016-06-042-2/+0
| | | | FTS: Remove stale reference to nfs4 fs which was removed in r192578.
* For EILSEQ case in mbsnrtowcs() and wcsnrtombs() update src to point toache2016-06-032-0/+3
| | | | | | | the character after the one this conversion stopped at. PR: 209907 Submitted by: Roel Standaert <roel@abittechnical.com> (partially)
* MFC r300662truckman2016-06-011-3/+6
| | | | | | | | | Fix Coverity CID 1016714 Resource leak in process_file_actions_entry() Don't leak a file descriptor of _dup2() fails (shouldn't happen). Reported by: Coverity CID: 1016714
* MFC r300660truckman2016-06-011-1/+3
| | | | | | | | | Fix 1016718 Resource leak. Don't leak a file descriptor if fchdir() fails. Reported by: Coverity CID: 1016718
* MFC r300378:pfg2016-05-291-9/+6
| | | | | | | | | | | | | libc/regex: fix two buffer underruns. 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. Obtained from: OpenBSD (CVS 1.20, 1.21)
* MFC r300420: vfork(2): Mention some risks of calling vfork() fromjilles2016-05-291-12/+28
| | | | application code.
* MFC: r300397ache2016-05-291-15/+10
| | | | | | | | | | | | | | 1) POSIX prohibits printing errors to stderr here and require 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 r299654:ngie2016-05-231-18/+15
| | | | | | | | | Read the contents of the snapshot files properly - 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 r299922truckman2016-05-231-1/+0
| | | | | | | | Don't call free_addrselectpolicy(&policyhead) before policyhead has been initialized. Reported by: Coverity CID: 1018727
* MFC r299879, r299880truckman2016-05-201-1/+1
| | | | | | | | | | | | | | | | | r299879 | truckman | 2016-05-15 18:30:32 -0700 (Sun, 15 May 2016) | 7 lines Likely a false positive ... but make sure that -1 can't be used as an array index by splitting up a test. r299880 | truckman | 2016-05-15 18:38:24 -0700 (Sun, 15 May 2016) | 8 lines Since rdata is only used as an argument to the immediately following 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
* MFC r298982:kib2016-05-161-8/+26
| | | | | | | Add EVFILT_VNODE open, read and close notifications. MFC r298984: Correct wording.
* MFC r298922:kib2016-05-161-2/+8
| | | | | | Issue NOTE_EXTEND when a directory entry is added to or removed from the monitored directory as the result of rename(2) operation. The renames staying in the directory are not reported.
* MFC r298898:kib2016-05-081-0/+4
| | | | Explain NOTE_LINK reporting for the directories.
* MFC r298893:bcr2016-05-061-1/+52
| | | | | | | | | | | | | Provide an example to the kqueue man page, showing 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 Differential Revision: https://reviews.freebsd.org/D6082
* MFC r298311,r298312:ngie2016-05-042-1/+2
| | | | | | | | | | | | | | | | | | | | | r298311: Make sure fmemopen succeeds in :test_append_binary_pos before calling ftell on the FILE object This fixes potential null pointer dereferences on failure CID: 1254952 r298312: Fix double fclose of `fp1` when freopen fails 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
* MFC r298521;pfg2016-04-281-2/+2
| | | | | | | | | | | regex: prevent two improbable signed integer overflows. 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 r298156:wblock2016-04-241-4/+4
| | | | Fix markup on "\n" in printf so it renders correctly.
* MFC r298303:ngie2016-04-221-2/+2
| | | | | Remove trailing whitespace and use `nitems(mib)` instead of `2` when calling sysctl(3)
* MFC r297475:brooks2016-04-131-1/+3
| | | | | | | Document KTRFAC_FAULT and KTRFAC_FAULTEND. Obtained from: CheriBSD (9d70f563f1b033e6a9b51eaf3b145a8cbbc6617c) Sponsored by: DARPA, AFRL
* MFC r297626:bdrewery2016-04-131-1/+2
| | | | | Follow-up r295924: Only sync hash-based db files open for writing when closing.
* MFC r297557:ache2016-04-111-1/+1
| | | | SJIS encoding don't have single byte characters >= 224
* MFC r287753: setuid(2): Suggest O_CLOEXEC instead of fcntl(F_SETFD).jilles2016-04-091-7/+2
|
* MFC r295384: semget(2): Add missing [EINVAL] conditions.jilles2016-04-081-1/+12
| | | | PR: 206927
* MFC r296278:pfg2016-03-311-2/+9
| | | | | | | | | | | | mbtowc(3): set errno to EILSEQ if an incomplete character is passed. According to POSIX, The mbtowc() function shall fail if: [EILSEQ] An invalid character sequence is detected. Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D5496 Obtained from: OpenBSD (Ingo Schwarze)
* MFC r296095:pfg2016-03-271-1/+1
| | | | | | | | rpc: fix failure to clear string by passing the wrong size to memset. Noted by NetBSD's PR/21014 Obtained from: NetBSD (CVS Rev. 1.24, 1.25)
* MFC r295416:bdrewery2016-03-121-1/+1
| | | | Fix the gcc build after r295407.
* MFC r268620,r294876,r294877:bdrewery2016-03-121-6/+3
| | | | | | | | | r268620: Make generation of nslexer.c more robust. r294876: nslexer.c does not depend on nsparser.h. r294877: Replace nslexer.l->nslexer.c custom rule with a -D CFLAG.
* MFC r295407:kib2016-03-123-2/+12
| | | | Make libc __pthread_map_stacks_exec() interposed.
* MFC:dwmalone2016-03-061-1/+5
| | | | | | | | | r295924: Make sure that hash-based db files fsync befor closing/syncing. r295925: We no longer need O_SYNC pwd_mkd r295465: We no longer need O_SYNC on services_mkdb r295800: We no longer need O_SYNC on cap_mkdb This should improve the performance of building db files.
* MFC r294597:wblock2016-02-061-1/+6
| | | | | | Add a standards compliance note for strtok_r Approved by: re (marius@)
* MFC r294691:sobomax2016-01-301-8/+16
| | | | | | Fix readpassphrase(3) when it's called with stdin being closed. Approved by: re (delphij)
* MFC r294515:brooks2016-01-281-7/+21
| | | | | | | | | | | | | Fix the implementations of PSEUDO_NOERROR and PSEUDO. The PSEUDO* macros should not declare <syscall>, only _<syscall> and __sys_<syscall>. This was causing the interposing C wrappers to be ignored due to link order. Reviewed by: kib Obtained from: CheriBSD (4e8e13c90fc6a80e1520de44a6864cfd78b3b56d) Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D4097
* MFC r294565: sem: Don't free nameinfo that is still in list when open()jilles2016-01-271-1/+3
| | | | | | | | | | | fails. This bug could be reproduced easily by calling sem_open() with O_CREAT | O_EXCL on a semaphore that is already open in the process. The struct sem_nameinfo would be freed while still in sem_list and later calls to sem_open() or sem_close() could access freed memory. PR: 206396
* MFC r294694:tuexen2016-01-271-2/+7
| | | | sctp_sendx() needs to provide the assoc_id back.
* MFC r294688:tuexen2016-01-271-0/+7
| | | | sctp_sendv() needs to fill in the association id on return.
* MFH (r291197): markup fixesdes2016-01-261-3/+9
|
* Revert r279010:pfg2016-01-261-6/+5
| | | | | | | | | | | | | | tdelete(3): don't delete the node we are about to return. The original change, from NetBSD, was bogus; introduced a memory leak and and broke POSIX. By reverting we actually match NetBSD's latest revision. This is a direct commit to 10 since this function was rewritten in 11-current. Reported by: Markiyan Kushnir Obtained from: NetBSD (CVS rev. 1.7, 1.8)
* MFC r294234: utimensat(2): Correct description of [EINVAL] error.jilles2016-01-211-3/+6
|
* MFC r293856:brooks2016-01-201-1/+1
| | | | | | | | | | | Avoid reading pass the end of the source buffer when it is not NUL terminated. If this buffer is adjacent to an unmapped page or a version of C with bounds checked is used this may result in a crash. PR: 206178 Submitted by: Alexander Cherepanov <cherepan@mccme.ru>
OpenPOWER on IntegriCloud