summaryrefslogtreecommitdiff
path: root/lib/libc
AgeCommit message (Collapse)Author
2022-07-31strlen was in v6 libc (s5/perror.c) but not documented till v7Jonathan Gray
ok schwarze@
2022-07-31fix indentTheo Buehler
2022-07-31Randomise the rekey interval a little. Previously, the chacha20Damien Miller
instance would be rekeyed every 1.6MB. This makes it happen at a random point somewhere in the 1-2MB range. Feedback deraadt@ visa@, ok tb@ visa@
2022-07-30we mention interim BSD releases so change some 4.4BSD use to 4.3BSD-RenoJonathan Gray
ok jmc@ schwarze@
2022-07-29Improve the HISTORY sections of glob(7) and glob(3).Ingo Schwarze
1. Make /etc/glob history less wordy and more precise: it was already in v1. 2. Remove the incorrect statement that the Bourne shell first integrated globbing. The PWB shell already did that in mid-1975, i.e. a least a few months before Stephen R. Bourne started working on his shell, and the PWB shell was publicly released with PWB/UNIX 1.0 about two years before v7. For details, see https://sjmulder.nl/dl/tuhs/Documentation/AUUGN/AUUGN-V06.6.pdf p. 39-40 OCR repost: https://groups.google.com/g/alt.folklore.computers/c/xW3ZgEnFoFs From: mash@mips.UUCP (John Mashey) Newsgroups: net.unix-wizards Subject: Re: Shell history, true facts, but long Date: 18 Mar 86 09:05:12 GMT [...] 3) The "PWB Shell" first appeared in mid-1975. [...] 4) The Bourne shell work started either in early 1976, or maybe late 1975. [...] In "The UNIX Shell", Stephen R. Bourne says: "The design of the shell is based in part on the original UNIX shell and the PWB/UNIX shell, some features having been taken from both." 3. Avoid the confusing statement that the glob() function first appeared in 4.4BSD. Actually, the PWB shell, the Bourne shell (in v7), the first UCB shell (in 1BSD), and the C shell (in 2BSD) all contained internal functions either called "glob()" or at least containing "glob" as a part of their function name. 4. Be more precise regarding when the current functions first appeared: they were already in Reno. Joint work with and OK jsg@. Feedback and OK jmc@.
2022-07-27Revert _RuneLocale struct changes until mklocale reacharoundPhilip Guenther
can be untangled. Problem noted by tb@
2022-07-27Since we only do US-ASCII and UTF-8, several parts of the localePhilip Guenther
data are unused and unnecessary, so delete them: rl_tabs, rl_magic, rl_encoding, and rl_invalid_rune. ok schwarze@
2022-07-26Only allow changing the domainname (from empty) before securelevel increase.Theo de Raadt
libc YP support has a couple of places where the domainname is cached, and this results in wildly incoherent behaviour which could even be risky. If you want to change the domainname, you will have to reboot. ok beck miod
2022-07-26moncontrol(3): remove hertz() fallback functionScott Soule Cheloha
In the moncontrol(3) code in libc there is a fallback function, hertz(). The idea is, if getting kern.clockrate from sysctl(2) fails, we fall back to deriving the value of hz(9) using setitimer(2)'s rounding behavior. This is extremely clever, but it actually sucks. Calling setitimer(2) quietly cancels any extant ITIMER_REAL timer, so moncontrol(3) cannot be safely used alongside setitimer(2). This fact is not documented. kern.clockrate is not blocked by pledge(2), so outside of stack corruption (which we can't do anything about anyway) I don't see a way for the sysctl(2) call to ever fail on OpenBSD. So hertz() is also pointless. Hence this patch: get rid of hertz(). Thread: https://marc.info/?l=openbsd-tech&m=163881542813633&w=2 ok guenther@
2022-07-25Simplify wctype() and wctype_l(): we have one set of classificationPhilip Guenther
types used by all (== both) locales; put their implementation in one file and make the mapping static there. The rl_wctype member of _RuneLocale and its initialization go away at the same time. ok schwarze@
2022-07-25If a command or interface first appeared in PWB/UNIX, UNIX System III orJonathan Gray
UNIX System V mention it. Only do so in manual pages with a pre-existing HISTORY section. Prompted by the comparison of System V and BSD commands and interfaces in Sun's "System V Enhancements Overview" document. checked against manuals on bitsavers, TUHS archive and CSRG archive CDs ok jmc@ schwarze@
2022-07-23timecounting: use full 96-bit product when computing elapsed timeScott Soule Cheloha
The timecounting subsystem computes elapsed time by scaling (64 bits) the difference between two counter values (32 bits at most) up into a struct bintime (128 bits). Under normal circumstances it is sufficient to do this with 64-bit multiplication, like this: struct bintime bt; bt.sec = 0; bt.frac = th->tc_scale * tc_delta(th); However, if tc_delta() exceeds 1 second's worth of counter ticks, that multiplication overflows. The result is that the monotonic clock appears to jump backwards. When can this happen? In practice, I have seen it when trying to compile LLVM on an EdgeRouter Lite when using an SD card as the backing disk. The box gets stuck in swap, the hardclock(9) is delayed, and we appear to "lose time". To avoid this overflow we need to compute the full 96-bit product of the delta and the scale. This commit adds TIMECOUNT_TO_BINTIME(), a function for computing that full product, to sys/time.h. The patch puts the new function to use in lib/libc/sys/microtime.c and sys/kern/kern_tc.c. (The commit also reorganizes some of our high resolution bintime code so that we always read the timecounter first.) Doing the full 96-bit multiplication is between 0% and 15% slower than doing the cheaper 64-bit multiplication on amd64. Measuring a precise difference is extremely difficult because the computation is already quite fast. I would guess that the cost is slightly higher than that on 32-bit platforms. Nobody ever volunteered to test, so this remains a guess. Thread: https://marc.info/?l=openbsd-tech&m=163424607918042&w=2 6 month bump: https://marc.info/?l=openbsd-tech&m=165124251401342&w=2 Committed after 9 months without review.
2022-07-22avoid use after freeJonathan Gray
ok deraadt@
2022-07-21repair error section; Martin VahlensieckTheo de Raadt
2022-07-19Use sysctl CTL_NET.PF_INET6 to check if IPv6 is available or not.Claudio Jeker
With this sysconf(3) no longer needs the inet pledge. The kernel has been updated for this for a while now. OK sthen@ deraadt@
2022-07-18ypbinding should not be intrude to application namespace.Theo de Raadt
spotted by guenther
2022-07-18use same way of reporting error as yp_bind.cTheo de Raadt
Though really, should we be splatting to stdout/stderr? The mysteries of ancient code...
2022-07-17order sysctl(2) Xr by sectionJonathan Gray
missed when sysctl(3) references were changed to sysctl(2)
2022-07-17fix a macro, and "new sentence, new line";Jason McIntyre
2022-07-17Delete mention of the old /var/run/ypbind.lock hack.Theo de Raadt
2022-07-17since yp_bind() and yp_all() don't use open, fstat, read, socket, and otherTheo de Raadt
rich system calls to perform YP/LDAP lookups, there is no need to access() /var/run/ypbind.lock to "hint" to pledge that it should open up those system calls. ok jmatthew, miod
2022-07-17Rather than opening the binding file, checking for advisory lock, reading aTheo de Raadt
piece of it for the address, opening a socket, and providing the address to the RPC clnt layer.. do all these steps with the magic system call ypconnect(2) which performs these steps without other system calls, and provides a socket which is not readily abuseable for other purposes. ok jmatthew, miod
2022-07-17Add ypconnect(2) stub inside libc so that libc functions can use it,Theo de Raadt
but do not export it.
2022-07-17add ypconnect(2) manual pageTheo de Raadt
2022-07-15Add a new clnt*_control CLSET_CONNECTED, which says the socket has alreadyTheo de Raadt
been connected. In the udp case, this means to use send(), not sendto() ok jmatthew, claudio, miod
2022-06-30To figure our whether a large allocation can be grown into thePhilip Guenther
following page(s) we've been first mquery()ing for it, mmapp()ing w/o MAP_FIXED if available, and then munmap()ing if there was a race. Instead, just try it directly with mmap(MAP_FIXED | __MAP_NOREPLACE) tested in snaps for weeks ok deraadt@
2022-06-20Fixup commentJeremie Courreges-Anglas
2022-06-16shmaddr is a pointer, so use NULL instead 0fTheo de Raadt
2022-06-10Add _?ENTRY_NB() macro for doing an ASM function entry withoutPhilip Guenther
setting the binding to global (NB == "no binding"), as clang 13 is now warning about changing the binding from global to weak. Use them for bcopy, brk, and sbrk. Add the '.L' prefix to internal labels in the bcopy implementation to remove them from the symbol table Start using the MI DEFS.h: delete the #defines from powerpc/SYS.h that the MI DEFS.h provides and switch from SYS.h to DEFS.h in files that don't do syscalls. Use END_BUILTIN from the MI DEFS.h for ffs. ok gkoehler@
2022-05-25Revert the .rodata.cst4 change: results in incorrect value readPhilip Guenther
2022-05-24Delete superfluous/duplicated #includesPhilip Guenther
2022-05-24Give internal 'botch' labels a '.L' prefix to remove them from thePhilip Guenther
symbol table ok kettenis@ miod@
2022-05-24Address the clang 13 "changed binding to STB_WEAK" warning on arm64:Philip Guenther
add _?ENTRY_NB to asm.h, switch libc's asm bits to the generic DEFS.h, and use ENTRY_NB as necessary. Also, give sizes to the htonl/htons symbols and mark them as weak. ok kettenis@ miod@
2022-05-24Set the correct alignment on __jmpxor (.align's meaning is MD!)Philip Guenther
Put .L_setjmp_magic in the correct ELF section for duplicate suppression Rename the "botch" label to delete it from the symbol table ok kettenis@ miod@
2022-05-24Delete superfluous/duplicated #includesPhilip Guenther
2022-05-24Add END() tags to give these functions sizes in the ELF symbol tablePhilip Guenther
ok kettenis@ miod@
2022-05-24Address the clang 13 "changed binding to STB_WEAK" warning on arm (32bit):Philip Guenther
* add _?ENTRY_NB to arm/asm.h * make sure ld.so's arm asm bits see the same includes as libc * switch libc's arm bits to the generic DEFS.h * switch arm ASM bits from ENTRY to ENTRY_NB as necessary ok kettenis@ miod@
2022-05-23Respect RLIMIT_FSIZE when extending a file via truncat(2)/ftruncate(2).Todd C. Miller
This refactors the commin parts of sys_truncate() and sys_ftruncate() into dotruncate(). If the new size of the file is larger than the RLIMIT_FSIZE limit _and_ the file is being extended, not truncated, return EFBIG. Adapted from a diff by Piotr Durlej. With help from and OK by deraadt@ guenther@.
2022-05-21system(3) should ignore SIGINT and SIGQUIT until the shell exits.Todd C. Miller
This got broken when system.c was converted from signal(3) to sigaction(2). Also add SIGINT and SIGQUIT to the set of blocked signals and unblock them in the parent after the signal handlers are installed. Based on a diff from Leon Fischer. OK deraadt@
2022-05-14Use fseeko() instead of fseek() inside libc, as the latter justPhilip Guenther
calls the former with a loss of range. Mark fseek symbol as deprecated to block accidental use in the future. ok millert@ deraadt@
2022-05-04Found two multiple evaluation macros. One of them so long and scary itTheo de Raadt
too many people to unravel correctly and place into a static function. While here, move the flags bits into local variables, which reduces the amount of () in the checks. help from millert, miod, tedu
2022-04-15delete an ancient paragraph suggesting the wrong reason to use close(2)Theo de Raadt
(and we all laughed a little)
2022-04-13Fix typo in last commit.Todd C. Miller
2022-04-13ftok: avoid left shift of a signed in by 24 placesTodd C. Miller
Fix "left shift of 255 by 24 places cannot be represented in type 'int'" error from UBSAN. Adapted from a FreeBSD diff via tb@. OK tb@ deraadt@
2022-04-13inet_net_pton_ipv6: avoid signed vs unsigned comparisonTodd C. Miller
Use a temporary variable to store the number of bytes to be copied (size_t) and also use it as the memcpy(3) length. Previously we copied "size" bytes instead of just the necessary number. OK claudio@ tb@
2022-03-31man pages: add missing commas between subordinate and main clausesChristian Weisgerber
jmc@ dislikes a comma before "then" in a conditional, so leave those untouched. ok jmc@
2022-03-29man pages: add missing word, The foo() ... -> The foo() function ...Christian Weisgerber
ok jmc@ schwarze@
2022-03-29Basic copy editing:Ingo Schwarze
Eliminate weasel words and needless parentheses, reduce "will" and "shall" and "may", add more precision, some grammar fixes, shorten and improve wordings, add some missing macros. Triggered by a question from naddy@.
2022-03-23Remove extra space at EOL in last commit.Todd C. Miller
2022-03-23Expand the description of the LOGIN_SET* bits.Todd C. Miller
Specifically, describe the default behavior if the corresponding login.conf fields are not present. OK deraadt@