summaryrefslogtreecommitdiff
path: root/lib/libc
Commit message (Collapse)AuthorAgeFilesLines
* MFC r320494: Fix double free by reverting r300385 and r300624 which wasXin LI2017-07-031-3/+1
| | | | | | | false positive reported by cppcheck. Notes: svn path=/stable/9/; revision=320583
* MFC r320216: Fix use-after-free introduced in r300388.Xin LI2017-06-251-1/+2
| | | | | | | | | | | | | | In r300388, endnetconfig() was called on nc_handle which would release the associated netconfig structure, which means tmpnconf->nc_netid would be a use-after-free. Solve this by doing endnetconfig() in return paths instead. Reported by: jemalloc via kevlo Reviewed by: cem, ngie (earlier version) Notes: svn path=/stable/9/; revision=320326
* MFC r309650:Ed Schouten2016-12-202-2/+9
| | | | | | | | | | | | Properly sign extend the result of jrand48() and mrand48(). These functions are supposed to return a value between [-2^31, 2^31). This doesn't seem to work on 64-bit systems, where we return a value between [0, 3^32). Patch up the function to use proper casts to int32_t. While there, fix some other style bugs. Notes: svn path=/stable/9/; revision=310321
* Merge rr309688: address regressions in SA-16:37.libc.Gleb Smirnoff2016-12-071-6/+5
| | | | | | | | PR: 215105 Submitted by: <jtd2004a sbcglobal.net> Notes: svn path=/stable/9/; revision=309691
* Merge r309639 from head:Gleb Smirnoff2016-12-061-17/+34
| | | | | | | | | | | | | | Fix possible buffer overflow(s) in link_ntoa(3). A specially crafted sockaddr_dl argument can trigger a static buffer overflow in the libc library, with possibility to rewrite with arbitrary data following static buffers that belong to other library functions. Reviewed by: kib Security: FreeBSD-SA-16:37.libc Notes: svn path=/stable/9/; revision=309646
* MFC r306075,r306109Andrey A. Chernov2016-09-281-14/+32
| | | | | | | | | | | | | | | | | | | | | 1) Microoptimize %p case. 2) Implememt %u for GNU compatibility. 3) Don't forget to advance buf for %w/%u. 4) Fail with incomplete week (week 0) request and no such week in the year. 5) Fix yday formula when Sunday requested and the week started from Monday. 6) Fail with impossible yday for incomplete week (week 0) and direct %w/%u request. 7) Shift yday/wday to the first day of the year, if incomplete week (week 0) requested and no %w/%u used. 8) For already non-standard %z extension implement GNU compatible formats: +hh and -hh. 9) Check for incorrect values for %z. PR: 212983 (case 3 only) Notes: svn path=/stable/9/; revision=306416
* MFC r272562,r272678,r272679Andrey A. Chernov2016-09-251-5/+6
| | | | | | | | | | | | 1) Fix the case we have less arguments for format string than we expected. 2) Return error on unsupported format specs. (both according to POSIX) 3) For %Z format, understand "UTC" name too. PR: 93197 (only r272679) Notes: svn path=/stable/9/; revision=306326
* MFstable/10 r304982:Enji Cooper2016-08-291-3/+5
| | | | | | | | | | | | | | | | | | MFstable/11 r304945: MFC r304034: Initialize `ai` to NULL and test for `ai` with type-appropriate values Depending on the address family and ai_flags containing AI_V4MAPPED, it might not do a proper DNS lookup on the provided DNS address Convert some `ai` boolean true/false checks to NULL/non-NULL while here. PR: 211790 Notes: svn path=/stable/9/; revision=304990
* MFC 304476: Fix various nits in the aio operation manpages.John Baldwin2016-08-223-20/+11
| | | | | | | | | | | | | | | | | | | | | - Avoid double use of "request" in a single sentence. Instead, describe aio_sigevent as being used to request notification of the associated operation's completion. This matches the language used to describe aio_sigevent in aio(4). - Simplify the prohibition on modifying buffers while requests are in flight. - Fix case mismatch. - Drop note about not using stack variables. C programmers should be able to figure out if a stack variable is safe based on the later warning about the life cycle requirements of control blocks. - Remove prohibition on modifying the I/O buffer for aio_fsync() since it does not use an I/O buffer. For aio_mlock(), prohibit modifications to the mapping (e.g. due to mprotect, munmap, mmap, etc.) but do not prohibit modifications to the memory backing the buffer (stores into the pages backing the buffer). Notes: svn path=/stable/9/; revision=304617
* MFC r301710:Mark Johnston2016-08-021-0/+4
| | | | | | | Fix an infinite loop in setnetgrent(3) with NIS netgroups. Notes: svn path=/stable/9/; revision=303681
* MFC 302899: Add documentation for the sigevent structure.John Baldwin2016-07-256-21/+163
| | | | | | | | | | | | | - Add a sigevent(3) manpage to give a general overview of the sigevent structure and the available notification mechanisms. - Document that AIO requests contain a nested sigevent structure that can be used to request completion notification. - Expand the sigevent details in other manuals to note details such as the extra values stored in a queued signal's information or in a posted kevent. Notes: svn path=/stable/9/; revision=303325
* MFstable/10 r302444:Enji Cooper2016-07-081-2/+2
| | | | | | | | | | | | | | MFC r301708: Revert r301707 getnetent_p doesn't return NULL like getnetent does. coccinelle got confused and I didn't verify that it worked before committing the change Pointyhat to: ngie Notes: svn path=/stable/9/; revision=302445
* MFstable/10 r302442:Enji Cooper2016-07-081-2/+2
| | | | | | | | | | | | MFC r301707: Use NULL instead of `0` in _ht_getnetbyname(..) - getnetent returns NULL on completion/error. - .h_aliases is NULL terminated. Notes: svn path=/stable/9/; revision=302443
* MFC r300683:Pedro F. Giffuni2016-06-242-24/+50
| | | | | | | | | | | | | | | | | | | | | | | | | libc: regexec(3) adjustment. 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) Notes: svn path=/stable/9/; revision=302169
* MFstable/10 r301820:Enji Cooper2016-06-111-1/+1
| | | | | | | | | MFC r301704: Test for strchr(3) returning NULL, not 0 Notes: svn path=/stable/9/; revision=301821
* MFstable/10 r301687:Enji Cooper2016-06-081-2/+3
| | | | | | | | | | | | | | | | | MFC r300624: 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 Notes: svn path=/stable/9/; revision=301688
* MFstable/10 r301684:Enji Cooper2016-06-081-0/+1
| | | | | | | | | MFC r300385: Don't leak `tmp` if `p->nc_lookups` can't be malloced Notes: svn path=/stable/9/; revision=301686
* MFstable/10 r301682:Enji Cooper2016-06-081-1/+3
| | | | | | | | | | | | MFC r300386: Don't leak `handle` if svc_tp_create(..) succeeds and allocating a new struct xlist object fails CID: 978277 Notes: svn path=/stable/9/; revision=301685
* MFstable/10 r301629:Enji Cooper2016-06-083-12/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MFC r300387,r300388,r300389: 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 Notes: svn path=/stable/9/; revision=301630
* MFC r300378:Pedro F. Giffuni2016-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) Notes: svn path=/stable/9/; revision=300964
* MFC r298521;Pedro F. Giffuni2016-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. Notes: svn path=/stable/9/; revision=298727
* MFstable/10 r298488:Enji Cooper2016-04-221-2/+2
| | | | | | | | | | MFC r298303: Remove trailing whitespace and use `nitems(mib)` instead of `2` when calling sysctl(3) Notes: svn path=/stable/9/; revision=298489
* MFC r296095:Pedro F. Giffuni2016-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) Notes: svn path=/stable/9/; revision=297320
* Revert r279011:Pedro F. Giffuni2016-01-261-5/+4
| | | | | | | | | | | | | | | | | 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 revert of the original merge: this function was rewritten in 11-current. Reported by: Markiyan Kushnir Obtained from: NetBSD (CVS rev. 1.7, 1.8) Notes: svn path=/stable/9/; revision=294763
* MFC 288833:Jason Helfman2016-01-251-6/+5
| | | | | | | | | | | | PR: 203440 (based on) Submitted by: ceratv@rpi.edu Approved by: wblock@ (mentor) Differential Revision: https://reviews.freebsd.org/D3813 - address grammar Notes: svn path=/stable/9/; revision=294746
* MFC r293856:Brooks Davis2016-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> Notes: svn path=/stable/9/; revision=294457
* MFC r293855:Brooks Davis2016-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: 206177 Submitted by: Alexander Cherepanov <cherepan@mccme.ru> Notes: svn path=/stable/9/; revision=294456
* MFstable/10 r294300:Enji Cooper2016-01-191-2/+2
| | | | | | | | | | | | | | | MFC r293715: Fix a mismerge from NetBSD in r162194 with `xdr_rpcb_entry_list_ptr(..)` This fixes the potential NULL pointer dereference properly, and also fixes memory leaks encountered in the process of iterating through `*rp`. Found by: Valgrind Submitted by: Miles Ohlrich <miles.ohlrich@isilon.com> Notes: svn path=/stable/9/; revision=294301
* MFstable/10 r294240:Enji Cooper2016-01-181-2/+2
| | | | | | | | | | | | | | MFC r293705: Similar to r293704, fix theoretical leak of netconfig(3) resources in __rpcbind_is_up(..) if getnetconfig(3) is partly successful in allocating resources, but not completely successful by moving the endnetconfig(3) call up before we return from the function if nconf == NULL. Submitted by: Miles Ohlrich <miles.ohlrich@isilon.com> Notes: svn path=/stable/9/; revision=294242
* MFstable/10 r294239:Enji Cooper2016-01-181-1/+1
| | | | | | | | | | | | | | | | | MFC r293704: Fix theoretical leak of netconfig(3) resources in svcunix_create(..) In the event that the getconfig(3) call in svcunix_create is partly successful, some of the netconfig(3) resources allocated might be leaked if the call returns NULL as endnetconfig(3) wasn't called explicitly in that case. Ensure that the resources are fully cleaned up by going to the `done` label, which will call endnetconfig(3) for us. Submitted by: Miles Ohlrich <miles.ohlrich@isilon.com> Notes: svn path=/stable/9/; revision=294241
* Merge r291073:Gleb Smirnoff2016-01-131-5/+28
| | | | | | | | | | | | | | | If a NIS server has long entries on its database that is bigger than 1024 specified on YPMAXRECORD the ypmatch can get in an infinite retry loop when is requesting the information from the NIS server. The ypmatch(1) will return an error until the command receives an kill(1). To avoid this problem, we check the MAX_RETRIES that is by default set to 20 and avoid get in infinet loop at the client side. Notes: svn path=/stable/9/; revision=293804
* MFC r292719:Hajimu UMEMOTO2016-01-012-57/+0
| | | | | | | | Remove _gethostbynisname() and _gethostbynisaddr(). These functions used to be called from getipnodebyname(). Notes: svn path=/stable/9/; revision=293024
* MFC r292550, r292595:Hajimu UMEMOTO2015-12-291-12/+4
| | | | | | | | Simplify _map_v4v6_address(). We don't need to use a temporary buffer, here. Notes: svn path=/stable/9/; revision=292851
* MFC r292445, r292554:Hajimu UMEMOTO2015-12-282-8/+6
| | | | | | | Use _map_v4v6_address(). Notes: svn path=/stable/9/; revision=292827
* MFC r292539:Hajimu UMEMOTO2015-12-281-1/+6
| | | | | | | | | | If we end up following a CNAME chain that does not find any data return that instead of internal error. PR: 156684 Notes: svn path=/stable/9/; revision=292825
* MFC r292514:Hajimu UMEMOTO2015-12-271-8/+8
| | | | | | | | | addrinfo.ai_family is an address family, not a protocol family. PR: 162434 Notes: svn path=/stable/9/; revision=292761
* MFC r292444, r292446:Hajimu UMEMOTO2015-12-252-28/+176
| | | | | | | | | Add AI_V4MAPPED and AI_ALL support for getaddrinfo(3). PR: 198092 Notes: svn path=/stable/9/; revision=292724
* MFstable/10 r292481:Enji Cooper2015-12-201-1/+1
| | | | | | | | | | | | | | MFC r292153: Add -static to CFLAGS to unbreak the tests by using a libc.a with the xlocale private symbols exposed which aren't exposed publicly via the DSO PR: 191354 Sponsored by: EMC / Isilon Storage Division Notes: svn path=/stable/9/; revision=292482
* MFC r289315,r292216Eric van Gyzen2015-12-193-4/+62
| | | | | | | | | | | | | | | | | | | | | | | resolver: automatically reload /etc/resolv.conf On each resolver query, use stat(2) to see if the modification time of /etc/resolv.conf has changed. If so, reload the file and reinitialize the resolver library. However, only call stat(2) if at least two seconds have passed since the last call to stat(2), since calling it on every query could kill performance. This new behavior is enabled by default. Add a "reload-period" option to disable it or change the period of the test. Document this behavior and option in resolv.conf(5). Polish the man page just enough to appease igor. Relnotes: yes Sponsored by: Dell Inc. Notes: svn path=/stable/9/; revision=292464
* MFC r289837Eric van Gyzen2015-12-191-39/+52
| | | | | | | | | | | | | | | | | | | resolver: abuse _res a little less In the past, _res was a global variable. Now, it's multiple function calls. Several functions in the resolver use _res multiple times and therefore call the function(s) far more than necessary. Fix those callers to store the result of _res in a local variable. Add __noinline to the definition of res_init() to avoid the code bloat that these changes would have otherwise incurred. Thanks to jilles for noticing this. Sponsored by: Dell Inc. Notes: svn path=/stable/9/; revision=292463
* MFC r292129:Hajimu UMEMOTO2015-12-191-1/+1
| | | | | | | | | | | | RFC 3493 requires ignoring the loopback address for AI_ADDRCONFIG. Since it breaks certain jail setup, we ignore just 127.0.0.1 instead of whole loopback address range. PR: 192014 Reviewed by: hrs Notes: svn path=/stable/9/; revision=292457
* MFstable/10 r292430:Enji Cooper2015-12-185-5/+15
| | | | | | | | | | | | | MFC r292250: Allow users override `DEBUG` on the command line via DEBUG_FLAGS="-DDEBUG" with lib/libc/resolv by conditionalizing its definition Reviewed by: ume, vangyzen Differential Revision: https://reviews.freebsd.org/D4519 Notes: svn path=/stable/9/; revision=292431
* MFC r292059:Hajimu UMEMOTO2015-12-171-1/+2
| | | | | | | | | | | The calls to RES_SET_H_ERRNO() macro on error paths wind up dereferencing an uninitialized res. PR: 202142 Submitted by: Sean Boudreau Notes: svn path=/stable/9/; revision=292404
* MFstable/10 r292170:Enji Cooper2015-12-133-4/+6
| | | | | | | | | | | | | | | MFC r291837: split.ih: - Create automatically generated include header for split.c main.c: - Use function definitions from debug.ih and split.ih instead of externs Sponsored by: EMC / Isilon Storage Division Notes: svn path=/stable/9/; revision=292171
* MFstable/10 r291602:Enji Cooper2015-12-133-27/+134
| | | | | | | | | | | | | | | | | | MFC r285140: r285140 (by oshogbo): Add fdclose(3) function. This function is equivalent to fclose(3) function except that it does not close the underlying file descriptor. fdclose(3) is step forward to make FILE structure private. Reviewed by: wblock, jilles, jhb, pjd Approved by: pjd (mentor) Differential Revision: https://reviews.freebsd.org/D2697 Notes: svn path=/stable/9/; revision=292154
* MFstable/10 r292150:Enji Cooper2015-12-132-4/+4
| | | | | | | | | | | | MFC r292013: Use stdint.h instead of inttypes.h as the latter pollutes namespace more Submitted by: bde Sponsored by: EMC / Isilon Storage Division Notes: svn path=/stable/9/; revision=292151
* MFstable/10 r292144:Enji Cooper2015-12-133-78/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MFC r291832,r291833,r291834,r291835,r291836,r291838: r291832: Fix -Wformat warnings by using the correct format qualifiers Sponsored by: EMC / Isilon Storage Division r291833: - Use ANSI C function prototypes/definitions instead of K&R style ones - Add a missing return type for main(..) Sponsored by: EMC / Isilon Storage Division r291834: Add missing headers and sort #includes per style(9) Sponsored by: EMC / Isilon Storage Division r291835: Use ANSI C function prototypes/definitions instead of K&R style ones Sponsored by: EMC / Isilon Storage Division r291836: Use `==` instead of `=` in the function comment above split(..) so mkh -p exposes split(..). Sponsored by: EMC / Isilon Storage Division r291838: Fix -Wformat issues and minor whitespace issues in surrounding areas Sponsored by: EMC / Isilon Storage Division Notes: svn path=/stable/9/; revision=292145
* MFstable/10 r292140:Enji Cooper2015-12-132-0/+6
| | | | | | | | | | | | | | | MFC r292004: Fix compilation when -DDEBUG is defined by adding inttypes.h #include for intmax_t Differential Revision: https://reviews.freebsd.org/D4434 Reported by: cppcheck Reviewed by: jhb Sponsored by: EMC / Isilon Storage Division Notes: svn path=/stable/9/; revision=292141
* MFstable/10 r292138:Enji Cooper2015-12-131-0/+1
| | | | | | | | | | | | MFC r291979: Unbreak compiling getnetgrent.c with -DDEBUG after r236402 by adding a missing "}" Sponsored by: EMC / Isilon Storage Division Notes: svn path=/stable/9/; revision=292139
* MFstable/10 r291871:Enji Cooper2015-12-061-0/+1
| | | | | | | | | MFC r291296: Link localeconv(3) to localeconv_l(3) Notes: svn path=/stable/9/; revision=291878