summaryrefslogtreecommitdiff
path: root/lib/libc
Commit message (Collapse)AuthorAgeFilesLines
* MFC r354255:Dimitry Andric2019-11-101-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add __isnan()/__isnanf() aliases for compatibility with glibc and CUDA Even though clang comes with a number of internal CUDA wrapper headers, compiling sample CUDA programs will result in errors similar to: In file included from <built-in>:1: In file included from /usr/lib/clang/9.0.0/include/__clang_cuda_runtime_wrapper.h:204: /usr/home/arr/cuda/var/cuda-repo-10-0-local-10.0.130-410.48/usr/local/cuda-10.0//include/crt/math_functions.hpp:2910:7: error: no matching function for call to '__isnan' if (__isnan(a)) { ^~~~~~~ /usr/lib/clang/9.0.0/include/__clang_cuda_device_functions.h:460:16: note: candidate function not viable: call to __device__ function from __host__ function __DEVICE__ int __isnan(double __a) { return __nv_isnand(__a); } ^ CUDA expects __isnan() and __isnanf() declarations to be available, which are glibc specific extensions, equivalent to the regular isnan() and isnanf(). To provide these, define __isnan() and __isnanf() as aliases of the already existing static inline functions __inline_isnan() and __inline_isnanf() from math.h. Reported by: arrowd PR: 241550 Notes: svn path=/stable/10/; revision=354596
* MF11 r347561.David E. O'Brien2019-05-141-0/+2
| | | | | | | MFC r344085: Note that readpassphrase() came into FreeBSD's libc at 4.6. Notes: svn path=/stable/10/; revision=347562
* MFC: 325765 (imp) Add notes about overlapping copies.Rodney W. Grimes2019-01-223-0/+25
| | | | | | | | | | | | | | Add notes to each of these that specifically state that results are undefined if the strings overlap. In the case of memcpy, we document the overlapping behavior on FreeBSD (pre-existing). For str*, it is left unspecified, however, since the default (and x86) implementations do not handle overlapping strings properly. PR: 223653 Approved by: phk (mentor) Notes: svn path=/stable/10/; revision=343326
* MFC r321333:Bryan Drewery2018-08-081-1/+1
| | | | | | | Properly set userid for truncate_test. Notes: svn path=/stable/10/; revision=337491
* MFC r328266:Alan Somers2018-08-031-3/+3
| | | | | | | | | | | | | | | | mlock(2): correct documentation for error conditions. The man page is years out of date regarding errors. Our implementation _does_ allow unaligned addresses, and it _does_not_ check for negative lengths, because the length is unsigned. It checks for overflow instead. Update the tests accordingly. Reviewed by: bcr Differential Revision: https://reviews.freebsd.org/D13826 Notes: svn path=/stable/10/; revision=337244
* MFC r292268, r334176Brooks Davis2018-05-315-10/+20
| | | | | | | | | | | | | | | | | | | | | | r292268: Remove sys/types.h due to STANDARDS and unistd.h also includes sys/types.h. r334176: Indicate the brk/sbrk are deprecated and not portable. More firmly suggest mmap(2) instead. Include the history of arm64 and riscv shipping without brk/sbrk. Mention that sbrk(0) produces unreliable results. Reviewed by: emaste, Marcin Cieślak Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D15535 Notes: svn path=/stable/10/; revision=334440
* MFC: r328834Marius Strobl2018-03-191-5/+3
| | | | | | | | | | | | | | | | | | o Let rtld(1) set up psABI user trap handlers prior to executing the objects' init functions instead of doing the setup via a constructor in libc as the init functions may already depend on these handlers to be in place. This gets us rid of: - the undefined order in which libc constructors as __guard_setup() and jemalloc_constructor() are executed WRT __sparc_utrap_setup(), - the requirement to link libc last so __sparc_utrap_setup() gets called prior to constructors in other libraries (see r122883). For static binaries, crt1.o still sets up the user trap handlers. o Move misplaced prototypes for MD functions in to the MD prototype section of rtld.h. o Sprinkle nitems(). Notes: svn path=/stable/10/; revision=331206
* MFC r330409:Brooks Davis2018-03-123-30/+36
| | | | | | | | | | | | | | | Refer to SysV IPC permissions as numeric constants. POSIX defines no macros for these permissions. Also remove unneeded headers from synopsis. PR: 225905 Reviewed by: wblock Differential Revision: https://reviews.freebsd.org/D14461 Notes: svn path=/stable/10/; revision=330801
* MFC 328630:John Baldwin2018-02-281-5/+10
| | | | | | | Clarify that the additional arguments to makecontext() are of type int. Notes: svn path=/stable/10/; revision=330133
* MFC r329848:Pedro F. Giffuni2018-02-281-2/+2
| | | | | | | | | | | | __printf_render_int(): small type change to match use. Variable l is consistently used as an int rather than a char. Sort names while here. Obtained from: Apple's Libc-1244.30.3 Notes: svn path=/stable/10/; revision=330097
* MFC r329846:Pedro F. Giffuni2018-02-281-2/+4
| | | | | | | | | | | | | getpeereid(3): Fix behavior on failure to match documentation. According to the getpeereid(3) documentation, on failure the value -1 is returned and the global variable errno is set to indicate the error. We were returning the error instead. Obtained from: Apple's Libc-1244.30.3 Notes: svn path=/stable/10/; revision=330095
* MFC of 328304 and 328382.Kirk McKusick2018-02-062-2/+19
| | | | | | | Do not dedup egid (group entry 0) Notes: svn path=/stable/10/; revision=328943
* MFC r327029:Hajimu UMEMOTO2017-12-271-1/+2
| | | | | | | | | Don't ignore trailing spaces after numerical IP addresses. PR: 224403 Notes: svn path=/stable/10/; revision=327238
* MFC r326122:Konstantin Belousov2017-11-301-2/+5
| | | | | | | | | | Kill all descendants of the reaper, even if they are descendants of a subordinate reaper. Also, mark reapers when listing pids. PR: 223745 Notes: svn path=/stable/10/; revision=326397
* MFC r326028:Pedro F. Giffuni2017-11-271-2/+2
| | | | | | | | | | | | iconv: Fix a pointer mismatch. Catch NULL pointer earlier, check for empty string later. Apparently this fixes a GCC8 warning. Obtained from: NetBSD (CVS Rev. 1.21, 1.22) through DragonFlyBSD Notes: svn path=/stable/10/; revision=326241
* MFC r325066:Pedro F. Giffuni2017-11-041-1/+1
| | | | | | | | | | | | | | | | | | | | Fix out-of-bounds read in libc/regex. The bug is an out-of-bounds read detected with address sanitizer that happens when 'sp' in p_b_coll_elems() includes NUL byte[s], e.g. if it's equal to "GS\x00". In that case len will be equal to 4, and the strncmp(cp->name, sp, len) call will succeed when cp->name is "GS" but the cp->name[len] == '\0' comparison will cause the read to go out-of-bounds. Checking the length using strlen() instead eliminates the issue. The bug was found in LLVM with oss-fuzz: https://reviews.llvm.org/D39380 Obtained from: Vlad Tsyrklevich through posting on openbsd-tech Notes: svn path=/stable/10/; revision=325394
* MFC r325030:Cy Schubert2017-11-041-1/+0
| | | | | | | Remove redundant sys/cdefs.h include. Notes: svn path=/stable/10/; revision=325381
* MFC r324243:Brooks Davis2017-10-141-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | Remove an unneeded and incorrect memset(). On Variant I TLS architectures (aarch64, arm, mips, powerpc, and riscv) the __libc_allocate_tls function allocates thread local storage memory with calloc(). It then copies initialization data over the portions with non-zero initial values. Before this change it would then pointlessly zero the already zeroed remainder of the storage. Unfortunately the calculation was wrong and it would zero TLS_TCB_SIZE (2*sizeof(void *)) additional bytes. In practice, this overflow only matters if the TLS segment is sized such that calloc() allocates less than TLS_TCB_SIZE extra memory. Even then, the likely result will be zeroing part of the next bucket. This coupled with the impact being confined to Tier II platforms means there will be no security advisory for this issue. Reviewed by: kib, dfr Discussed with: security-officer (delphij) Found by: CHERI Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D12547 Notes: svn path=/stable/10/; revision=324617
* MFC r324249, 324260, and 324277Cy Schubert2017-10-111-8/+9
| | | | | | | Clarify the wording describing the stayopen flag and style fixes. Notes: svn path=/stable/10/; revision=324515
* MFC r322368, r322371:Pedro F. Giffuni2017-10-102-2/+3
| | | | | | | | | | | | | | | | | fnmatch(3): improve POSIX conformance. In a recent interpretation[1], "\\" shall return a non-zero value (indicating either no match or an error). The fix involves a change over r254091 and now the behavior matches the Sun/IBM/HP closed source implementations and also likely musl libc. Submitted by: Joerg Schilling <joerg at schily.net> [1] http://austingroupbugs.net/view.php?id=806 Notes: svn path=/stable/10/; revision=324505
* MFC r320737, r320914Alan Somers2017-08-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | r320737: Fix cleanup in lib/libc/gen/setdomainname_test ATF cleanup routines run in separate processes from the tests themselves, so they can't share global variables. Also, setdomainname_test needs to be is_exclusive because the test cases access a global resource. PR: 219967 Reviewed by: ngie Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D11188 r320914: Remove an extraneous strlen from t_setdomainname.c Reported by: Coverity CID: 1377568 X-MFC-With: 320737 Sponsored by: Spectra Logic Corp Notes: svn path=/stable/10/; revision=321878
* Clarify usage of aio(4) with kqueue(2)Alan Somers2017-07-311-26/+11
| | | | | | | | | Reviewed by: jhb MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D11299 Notes: svn path=/stable/10/; revision=321829
* Merge MAP_GUARD.Konstantin Belousov2017-07-302-6/+45
| | | | | | | | | | | MFC r316687 (by markj), r320314, r320317, r320338, r320339, r320344, r320430, r320560 (by alc), r320801, r320843, r321173, r321230. Tested by: pho Sponsored by: The FreeBSD Foundation Notes: svn path=/stable/10/; revision=321717
* MFC note: content changes of r317315 were reversed. .Dd is being updatedEnji Cooper2017-07-191-1/+1
| | | | | | | | | | | | | | | | | for diff reduction purposes. MFC r317315,r317437: r317315: Note that getpagesize(3) can return -1 on failure r317437 (by kib): getpagesize(3) cannot fail. Notes: svn path=/stable/10/; revision=321249
* MFC r318706:Enji Cooper2017-07-181-1/+2
| | | | | | | localeconv(3): start sentences on new lines Notes: svn path=/stable/10/; revision=321160
* MFC r318712:Enji Cooper2017-07-181-1/+1
| | | | | | | | | xdr(3): add missing comma after xdr_sizeof(3) in SYNOPSIS This unbreaks the .Nm declaration Notes: svn path=/stable/10/; revision=321157
* MFC r318703:Enji Cooper2017-07-181-1/+1
| | | | | | | __iconv_get_list: separate .Nm entries with commas Notes: svn path=/stable/10/; revision=321155
* MFC r318707:Enji Cooper2017-07-181-2/+2
| | | | | | | sctp_send(3): start sentences on new lines Notes: svn path=/stable/10/; revision=321154
* MFC r318704,r318708,r318709:Enji Cooper2017-07-183-4/+5
| | | | | | | | | | | | | | | | | r318704: posix1e(3): reference using the section (3) when referencing libbsm with .Xr r318708: acl_create_entry(3): separate .Nm entries with commas in SYNOPSIS r318709: acl_to_text(3): start sentences on new lines Notes: svn path=/stable/10/; revision=321149
* MFC r318710:Enji Cooper2017-07-181-3/+3
| | | | | | | quick_exit(3): delete trailing whitespace in licensing tort Notes: svn path=/stable/10/; revision=321148
* MFC r318718,r318719,r318720,r318721:Enji Cooper2017-07-184-17/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | r318718: rctl_add_rule(2): fix manlint warnings - Fix commas (either missing or misused) after .Nm entries in SYNOPSIS r318719: open(2): fix manlint warnings - Sort SEE ALSO .Xr entries. - Sort sections (HISTORY comes after STANDARDS). r318720: ptrace(2): clean up trailing whitespace r318721: kill(2): add missing section for sysctl(9) Notes: svn path=/stable/10/; revision=321146
* MFC r319048,r319049,r319051,r319054:Enji Cooper2017-07-183-35/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r319048: Push `snapshot_file` copying down into run_tests function, and mark snapshot_file const char *. This fixes a bogus set of errors from gcc about strdup not being allowed a NULL argument. r319049: Bump WARNS from 1 to 3 after recent commits to fix warnings in the directory. Tested with: clang 4.0, gcc 4.2.1, gcc 6.3.0 r319051: hostent_test_getnameinfo_eq(..): initialize found_a_host to false CID: 1368943 r319054: hostent_test_getaddrinfo_eq(..): call freeaddrinfo on `ai` when done This plugs a leak of memory allocated via getaddrinfo. CID: 1346866 Notes: svn path=/stable/10/; revision=321144
* MFC r319842:Enji Cooper2017-07-181-2/+3
| | | | | | | | | | | | getbsize(3): clarify that underflow/overflow warnings in regard to $BLOCKSIZE gets output via warnx(3) This helps set expectations for how one might deal with those messages, i.e., mute output from /dev/stderr today, since that's where vwarn(3) outputs messages to today. Notes: svn path=/stable/10/; revision=321127
* MFC r318695:Enji Cooper2017-07-181-4/+4
| | | | | | | | | err(3): use `NULL`, aka `(void*)0` per POSIX instead of `(FILE *)0` This is being done to aid humans and static analysis checkers. Notes: svn path=/stable/10/; revision=321124
* MFC r318705:Enji Cooper2017-07-181-5/+10
| | | | | | | | | | | fopen(3): make manlint fixes - Break on new lines. - Use .Dv with NULL. - Rewrap lines as necessary/when possible. Notes: svn path=/stable/10/; revision=321120
* MFC r320472,r320508,r320509:Konstantin Belousov2017-07-1739-139/+191
| | | | | | | | | Make stdio deferred cancel-safe. Requested by: eugen Notes: svn path=/stable/10/; revision=321074
* MFC r320570:Konstantin Belousov2017-07-091-4/+5
| | | | | | | Correct signatures of several pthreads stubs. Notes: svn path=/stable/10/; revision=320823
* 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/10/; revision=320582
* 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/10/; revision=320325
* MFC r320052:Konstantin Belousov2017-06-241-21/+25
| | | | | | | Do not leak syslog_mutex on cancellation. Notes: svn path=/stable/10/; revision=320312
* MFC 319490: Remove stale cap_rights_get(2) manpage.John Baldwin2017-06-201-1/+0
| | | | | | | | | | | The documentation moved to section 3 several years ago, but 'man cap_rights_get' pulls up cap_rights_limit(2) (which is MLINKed to cap_rights_get.2) instead of cap_rights_get(3). Approved by: re (gjb) Notes: svn path=/stable/10/; revision=320150
* MFC r319369:Xin LI2017-06-064-17/+47
| | | | | | | | | | | | | | | | * limit size of buffers to RPC_MAXDATASIZE * don't leak memory * be more picky about bad parameters From: https://raw.githubusercontent.com/guidovranken/rpcbomb/master/libtirpc_patch.txt https://github.com/guidovranken/rpcbomb/blob/master/rpcbind_patch.txt via NetBSD. Notes: svn path=/stable/10/; revision=319615
* MFC r318450:Konstantin Belousov2017-06-012-0/+103
| | | | | | | | | Add tests for some cases in r318298. PR: 219154 Notes: svn path=/stable/10/; revision=319419
* MFC r319086:Konstantin Belousov2017-05-311-2/+5
| | | | | | | Mention that the basep argument to getdirentries(2) can be NULL. Notes: svn path=/stable/10/; revision=319311
* MFC ↵Enji Cooper2017-05-319-97/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r319027,r319028,r319029,r319030,r319031,r319033,r319034,r319035,r319036,r319037,r319038,r319039,r319040,r319041,r319042,r319043,r319044,r319045,r319046: r319027: lib/libc/tests/nss: use calloc appropriately The pattern used prior to this commit was `calloc(1, n * sizeof(type))`; the pattern that should be used however is `calloc(n, sizeof(type))`. r319028: Sort make variables to suit style.Makefile(5) This is being done prior to functional changes. r319029: Staticize functions and remove unused variables to aid with bumping WARNS r319030: Fix -Wsign-compare warnings r319031: getusershell_test: staticize run_tests(..) to fix warnings r319033: getserv_test: fix -Wsign-compare and -Wmissing-prototypes warnings r319034: getaddrinfo_test: fix -Wsign-compare warnings r319035: getrpc_test: fix -Wmissing-prototypes and -Wsign-compare warnings r319036: getproto_test: fix -Wmissing-prototypes and -Wsign-compare warnings r319037: getaddrinfo_test: mark unused function parameters __unused to fix -Wunused warnings r319038: getusershell_test: mark mdata parameter in compare_usershell __unused r319039: getserv_test: mark unused parameters __unused to fix corresponding warnings r319040: getrpc_test: fix -Wunused warnings - Mark unused function parameters unused. - Remove an unused function prototype. r319041: getproto_test: fix -Wunused warnings Mark unused parameters __unused in functions. r319042: gethostby_test: fix multiple warning types - Fix -Wmissing-declaration warning by staticizing run_tests. - Fix -Wsign-compare warnings by casting size_t types to int for comparisons. Reindent some of the code in sdump_hostent(..) to accomodate the overall changes. r319043: getpw_test: fix -Wunused warnings - Mark unused parameters __unused. - Put dump_passwd under DEBUG as it's only used in that case. r319044: getgr_test: fix -Wunused warnings r319045: Fix -Wunused and -Wshadow warnings r319046: Fix a -Wunused-but-set-variable warning reported by gcc 6.3.0 Notes: svn path=/stable/10/; revision=319298
* MFC r318514-r318515, r318517, r318917Xin LI2017-05-311-18/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r318514: Use size_t. Inspired by: OpenBSD src/lib/libc/stdlib/qsort.c,v 1.11 r318515: The current qsort(3) implementation ignores the sizes of partitions, and always perform recursion on the left partition, then use a tail call to handle the right partition. In the worst case this could require O(N) levels of recursions. Reduce the possible recursion level to log2(N) by always recursing on the smaller partition instead. Obtained from: PostgreSQL 9d6077abf9d6efd992a59f05ef5aba981ea32096 r318517: Sync qsort.c with userland r318515. (Note that MIN macro is removed in favor of sys/param.h's version). PR: 213922 r318917: Disconnect heimdal version of qsort.c from build because we are already using libc's version of qsort. PR: bin/213922 Notes: svn path=/stable/10/; revision=319291
* Partial MFC r288030 (rodrigc):Xin LI2017-05-311-3/+1
| | | | | | | Use ANSI C prototypes. Eliminates -Wold-style-definition warnings. Notes: svn path=/stable/10/; revision=319290
* MFC r279663,r279666 (pfg):Xin LI2017-05-311-22/+31
| | | | | | | | | | | | | | | | | | | | | | | r279663: qsort(3): enhance to handle 32-bit aligned data on 64-bit systems Implement a small enhancement to the original qsort implementation: If the data is 32 bit aligned we can side-step the long type version and use int instead. The change brings a modest but significant improvement in 32 bit workloads. r279666: qsort(3): small style(9) cleanups. Basically spaces vs. tabs. No functional change. Notes: svn path=/stable/10/; revision=319289
* MFC r315272, r315370Xin LI2017-05-311-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | r315272: Implement INHERIT_ZERO for minherit(2). INHERIT_ZERO is an OpenBSD feature. When a page is marked as such, it would be zeroed upon fork(). This would be used in new arc4random(3) functions. PR: 182610 Reviewed by: kib (earlier version) Differential Revision: https://reviews.freebsd.org/D427 r315370: The adj_free and max_free values of new_entry will be calculated and assigned by subsequent vm_map_entry_link(), therefore, remove the pointless copying. Submitted by: alc Notes: svn path=/stable/10/; revision=319278
* MFC r315032-r315036, r315039, r315041Alan Somers2017-05-302-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r315032: Increase WARNS for iconv tests ATF tests have a default WARNS of 0, unlike other usermode programs. Reviewed by: ngie Sponsored by: Spectra Logic Corporation Differential Revision: https://reviews.freebsd.org/D9933 r315033: Increase WARNS for nss tests ATF tests have a default WARNS of 0, unlike other usermode programs. Reviewed by: ngie Sponsored by: Spectra Logic Corporation Differential Revision: https://reviews.freebsd.org/D9933 r315034: Document that the msun tests require WARNS=0 ATF tests have a default WARNS of 0, unlike other usermode programs. This change is technically a noop, but it documents that the msun tests don't work with any warnings enabled, at least not on all architectures. Reviewed by: ngie Sponsored by: Spectra Logic Corporation Differential Revision: https://reviews.freebsd.org/D9933 r315035: Increase WARNS for libcrypt tests ATF tests have a default WARNS of 0, unlike other usermode programs. Reviewed by: ngie, julian Sponsored by: Spectra Logic Corporation Differential Revision: https://reviews.freebsd.org/D9933 r315036: Increase WARNS for libmp tests ATF tests have a default WARNS of 0, unlike other usermode programs. Reviewed by: ngie, julian Sponsored by: Spectra Logic Corporation Differential Revision: https://reviews.freebsd.org/D9933 r315039: Increase WARNS for libutil tests ATF tests have a default WARNS of 0, unlike other usermode programs. Reviewed by: ngie, julian Sponsored by: Spectra Logic Corporation Differential Revision: https://reviews.freebsd.org/D9933 r315041: Increase WARNS for pw tests ATF tests have a default WARNS of 0, unlike other usermode programs. Reviewed by: ngie, julian Sponsored by: Spectra Logic Corporation Differential Revision: https://reviews.freebsd.org/D9933 Notes: svn path=/stable/10/; revision=319252