| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
| |
This matches the man page for qsort_s().
PR: 281828
Signed-off-by: Graham Percival <gperciva@tarsnap.com>
Sponsored by: Tarsnap Backup Inc.
(cherry picked from commit d0a3fd34a05794bc5cbf48709001a78e9f85169a)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously a stream opened as read-only could be written to. Add a test
case for the fix.
Also correct another incorrect access mode check that worked by
accident, and improve the tests for that.
PR: 281953
Reported by: Erkki Moorits, fuz
Reviewed by: fuz, khng (earlier)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47265
(cherry picked from commit 0953460ce149e6f384aafbcb1e6213dfbf8f6a16)
(cherry picked from commit 6b9f7133aba44189d9625c352bc2c2a59baf18ef)
(cherry picked from commit 4fbd6e0e3ca8e69d2d3789ecda6e4dd76c34e06a)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The manual page says %m is replaced with “the string representation of
the error code stored in the errno variable at the beginning of the
call”. However, we don't actually save `errno` until fairly late in
`__vfprintf()`. Make sure it is saved before we do anything that
might perturb `errno`.
MFC after: 1 week
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D46718
(cherry picked from commit 74f1007fcc838501c74a633792c3f01833bf65e1)
|
|
|
|
| |
(cherry picked from commit aa66995b4c804cbb579f71645d97fe282a798bfc)
|
|
|
|
| |
(cherry picked from commit bac9d7e8f2931149815c3d5a9ab69594bbdffde6)
|
|
|
|
|
|
| |
PR: 278556
(cherry picked from commit f887667694632c829b0599b54ff86a072e93df87)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Two additional stdio changes followed 86a16ada1ea6 and need to be
reverted as part of the fflush fix.
This reverts commit 6e13794fbe6e82c21365d0fd66769bf8b19c0197.
This reverts commit bafaa70b6f9098d83d074968c8e6747ecec1e118.
Fixes: d09a3bf72c0b ("fflush: correct buffer handling in __sflush")
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42491
(cherry picked from commit 4e0e01bf6511c28212d7dff94fe131a502e13026)
(cherry picked from commit d2c65a1c948648f11342274029a3f18b90aa58d2)
Approved by: so
|
|
|
|
|
|
|
|
|
|
|
|
| |
errno.h was added in 44cf1e5eb470, which has been reverted.
Fixes: d09a3bf72c0b ("fflush: correct buffer handling in __sflush")
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 418f026bd5a5084c1c4e2e91ad38051f6caa928c)
(cherry picked from commit abe12d2f4ce31c3da0961b1b0a58df11f5a41e19)
Approved by: so
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes CVE-2014-8611 correctly.
The commit that purported to fix CVE-2014-8611 (805288c2f062) only hid
it behind another bug. Two later commits, 86a16ada1ea6 and
44cf1e5eb470, attempted to address this new bug but mostly just confused
the issue. This commit rolls back the three previous changes and fixes
CVE-2014-8611 correctly.
The key to understanding the bug (and the fix) is that `_w` has
different meanings for different stream modes. If the stream is
unbuffered, it is always zero. If the stream is fully buffered, it is
the amount of space remaining in the buffer (equal to the buffer size
when the buffer is empty and zero when the buffer is full). If the
stream is line-buffered, it is a negative number reflecting the amount
of data in the buffer (zero when the buffer is empty and negative buffer
size when the buffer is full).
At the heart of `fflush()`, we call the stream's write function in a
loop, where `t` represents the return value from the last call and `n`
the amount of data that remains to be written. When the write function
fails, we need to move the unwritten data to the top of the buffer
(unless nothing was written) and adjust `_p` (which points to the next
free location in the buffer) and `_w` accordingly. These variables have
already been set to the values they should have after a successful
flush, so instead of adjusting them down to reflect what was written,
we're adjusting them up to reflect what remains.
The bug was that while `_p` was always adjusted, we only adjusted `_w`
if the stream was fully buffered. The fix is to also adjust `_w` for
line-buffered streams. Everything else is just noise.
Fixes: 805288c2f062
Fixes: 86a16ada1ea6
Fixes: 44cf1e5eb470
Sponsored by: Klara, Inc.
(cherry picked from commit d09a3bf72c0b5f1779c52269671872368c99f02a)
(cherry picked from commit 92709431b14df6c0687446247ac57cfc189ee827)
Approved by: so
|
|
|
|
|
|
|
|
|
|
| |
It is clearer to avoid reusing temporary variables for different
purposes.
Sponsored by: Klara, Inc.
(cherry picked from commit 1f90b4edffe815aebb35e74b79e10593b31f6b75)
(cherry picked from commit 1e99535be2ea9c0ef8bc57fc885e9c01fa95d2dd)
|
|
|
|
|
|
|
|
| |
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 7fde0187cc443468561f0a30d589ff0cfe45eef5)
(cherry picked from commit 560e22c8fe460e00d16e5268fe1fbb316ad81101)
(cherry picked from commit 5b5fa75acff11d871d0c90045f8c1a58fed85365)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
While here, also update a mention of ANSI C.
Sponsored by: Klara, Inc.
Reviewed by: kevans, markj
Differential Revision: https://reviews.freebsd.org/D41686
(cherry picked from commit 5a57401e7106132b61b16e34365cebf52b773007)
libc: Further nit in fopen(3) man page.
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D41687
(cherry picked from commit c9f5889d05b5854be033849a4ff9985699071548)
|
|
|
|
|
|
|
| |
Remove /^\.\\"\s*\$FreeBSD\$$\n/
Similar commit in main:
(cherry picked from commit b2c76c41be32)
|
|
|
|
|
|
|
| |
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
Similar commit in main:
(cherry picked from commit fa9896e082a1)
|
|
|
|
|
|
|
| |
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
Similar commit in main:
(cherry picked from commit d0b2dbfa0ecf)
|
|
|
|
|
|
|
| |
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
Similar commit in main:
(cherry picked from commit 1d386b48a555)
|
|
|
|
|
|
|
| |
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
Similar commit in main:
(cherry picked from commit 42b388439bd3)
|
|
|
|
|
|
|
| |
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
Similar commit in main:
(cherry picked from commit b3e7694832e8)
|
|
|
|
|
|
|
|
|
|
|
| |
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.
Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix
(cherry picked from commit 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
|
|
|
|
|
|
|
|
|
|
| |
From enh at google.com via openbsd-tech mailing list via pfg@:
The existing test is wrong for LP64, where size_t has twice as many
relevant bits as int, not just one. (Found by inspection by
rprichard.)
(cherry picked from commit 9515313b26beb005a521aff2e6edd4d75cd010da)
|
|
|
|
|
|
| |
PR: 266171
(cherry picked from commit 44cf1e5eb470380442fa8e240e213a71b8fe81d4)
|
|
|
|
| |
(cherry picked from commit 120bacabfd4f383f028bb309581e2366110d0c28)
|
|
|
|
|
|
|
|
|
|
|
| |
There are some sections which could be improved
and work to do so is on going. The work will be
covered via 'X-MFC-WITH' commits.
Obtained from: OpenBSD
Differential Revision: https://reviews.freebsd.org/D34759
(cherry picked from commit 4b7f35db44cbf901e994fc9a4bcd4c98ebe8c4a1)
|
|
|
|
|
|
|
|
|
|
| |
This is akin to commit bafaa70b6f9098d83d074968c8e6747ecec1e118.
Reported by: Guy Yur <guyyur@gmail.com>
Fixes: 86a16ada1ea6
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 6e13794fbe6e82c21365d0fd66769bf8b19c0197)
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
__sfvwrite() advances the pointer before calling fflush. If fflush()
fails, it is not enough to roll back inside it, because we cannot know
how much was advanced by the caller.
Reported by: Peter <pmc@citylink.dinoex.sub.org>
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Fixes: 86a16ada1ea608408cec370171d9f59353e97c77
(cherry picked from commit bafaa70b6f9098d83d074968c8e6747ecec1e118)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A case of undefined behavior in __fread() has been detected by UBSAN
and reported by Mark Millard:
/usr/main-src/lib/libc/stdio/fread.c:133:10: runtime error: applying
zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior in
/usr/main-src/lib/libc/stdio/fread.c:133:10
While being benign (the NULL pointer is later passed to memcpy() with
a length argument of 0), this issue causes in the order of 600 Kyua
test cases to fail on systems running a world built with WITH_UBSAN
and WITH_ASAN.
The undefined behavior can be prevented by skipping operations that
have no effect for r == 0. Mark Millard has suggested to only skip
this code segment if fp->_p == NULL, but I have verified that for the
case of r == 0 no further argument checking is performed on the
addresses passed to memcpy() and thus no bugs are hidden from the
sanitizers due to the simpler condition chosen.
(cherry picked from commit 10af8e45a89818754b80315539e167ae49599f17)
|
|
|
|
|
|
| |
PR: 76398
(cherry picked from commit 86a16ada1ea608408cec370171d9f59353e97c77)
|
|
|
|
| |
(cherry picked from commit c8a4a49d582f539c73ef436ceb9d623dd9f20221)
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We can use the buffer passed to fread(3) directly in the FILE *.
The buffer needs to be reset before each call to __srefill().
This preserves the expected behavior in all cases.
The change was found originally in OpenBSD and later adopted by NetBSD.
MFC after: 2 weeks
Obtained from: OpenBSD (CVS 1.18)
Differential Revision: https://reviews.freebsd.org/D30548
|
|
|
|
| |
(cherry picked from commit b22fdf45ff8ef1d1f9a6c28f1d7f59ca4b012da6)
|
|
|
|
| |
(cherry picked from commit 6fe328ace8f418bab0ab7f78c6fa1f2e757dd8a9)
|
|
|
|
|
|
|
| |
It was only done to catch ENOTDIR, but the kernel already returns the
error where appropriate.
(cherry picked from commit 97a463120bf99819fcb21a781e410fb43dde2a43)
|
|
|
|
|
|
|
|
|
| |
PR: 181785
Submitted by: Kevin P. Neal <kpneal atpobox dot com>
MFC after: 1 week
Notes:
svn path=/head/; revision=364029
|
|
|
|
|
|
|
|
|
|
|
| |
Reviewed by: yuripv, bcr (mentor)
Approved by: bcr (mentror)
Obtained from: OpenBSD
MFC after: 7 days
Differential Revision: https://reviews.freebsd.org/D24916
Notes:
svn path=/head/; revision=362326
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Add STANDARDS and HISTORY sections within the appropriate manpages
- Mention two USENIX papers within kqueue(2) and strlcpy(3)
Reviewed by: bcr (mentor)
Approved by: bcr (mentor)
Obtained from: NetBSD
MFC after: 7 days
Differential Revision: https://reviews.freebsd.org/D24650
Notes:
svn path=/head/; revision=362171
|
|
|
|
|
|
|
|
|
| |
PR: 240269
Submitted by: Gordon Bergling
Differential Revision: https://reviews.freebsd.org/D24295
Notes:
svn path=/head/; revision=359773
|
|
|
|
|
|
|
|
|
| |
These functions first appeared in the First Edition of Unix (or earlier in the
pdp-7 version). Just claim 1st Edition for all this. The pdp-7 code is too
fragmented at this point to extend history that far back.
Notes:
svn path=/head/; revision=359547
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Among the same justification as the other stdio _unlocked; in addition to an
inline version in <stdio.h>, we must provide a function in libc as well for
the functionality. This fixes the lang/gcc* builds, which want to use the
symbol from libc.
PR: 243810
Reported by: antoine, swills, Michael <michael.adm gmail com>
X-MFC-With: r357284
Notes:
svn path=/head/; revision=357419
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
fflush_unlocked is currently desired in ports by sysutils/metalog, and
redefined as the locked fflush.
fputc_unlocked, fputs_unlocked, fread_unlocked, and fwrite_unlocked are
currently desired in ports by devel/elfutils, and redefined as the locked
fputs, fread, and fwrite respectively.
Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D23336
Notes:
svn path=/head/; revision=357284
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
gets is unsafe and shouldn't be used (for many years now). Leave it in
the existing symbol version so anything that previously linked aginst it
still runs, but do not allow new software to link against it.
(The compatability/legacy implementation must not be static so that
the symbol and in particular the compat sym gets@FBSD_1.0 make it
into libc.)
PR: 222796 (exp-run)
Reported by: Paul Vixie
Reviewed by: allanjude, cy, eadler, gnn, jhb, kib, ngie (some earlier)
Relnotes: Yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D12298
Notes:
svn path=/head/; revision=351659
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a variant of mkostemps() which takes a directory descriptor and
returns a descriptor for a tempfile relative to that directory. Unlike
the other mktemp functions, mkostempsat() can be used in capability
mode.
Reviewed by: cem
Discussed with: brooks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21031
Notes:
svn path=/head/; revision=350420
|
|
|
|
|
|
|
|
|
|
|
|
| |
Back in 1993, the fgetln (then fgetline) interface was changed to not
return a C string. The change was accomplished by ifdefing out the code
that did the termination. Changing the interface would violate our API
stability rules so remove the old implementation.
Sponsored by: DARPA, AFRL
Notes:
svn path=/head/; revision=343884
|
|
|
|
|
|
|
|
|
|
| |
gets(3) does. This was missed in r331936.
Reported by: emaste@
MFC after: 3 days
Notes:
svn path=/head/; revision=339656
|
|
|
|
|
|
|
|
| |
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Notes:
svn path=/head/; revision=339458
|
|
|
|
|
|
|
|
|
| |
Reviewed by: ed, dim (code only)
Sponsored by: Mellanox Technologies
MFC after: 1 week
Notes:
svn path=/head/; revision=334031
|
|
|
|
|
|
|
|
| |
Prompted by: Recent discussion
MFC after: 3 days
Notes:
svn path=/head/; revision=333895
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
output, from this:
strnlen, strlen, strlen,(3) - find length of string │·······
... to this:
strlen, strnlen(3) - find length of string
PR: 223525
MFC after: 2 weeks
Notes:
svn path=/head/; revision=332642
|
|
|
|
|
|
|
|
|
|
| |
Reported by: kib@
MFC after: 2 weeks
X-MFC with: r331936
Differential Revision: https://reviews.freebsd.org/D12785
Notes:
svn path=/head/; revision=331947
|
|
|
|
|
|
|
|
|
|
| |
Reported by: kib@
MFC after: 2 weeks
X-MFC with: r331936
Differential Revision: https://reviews.freebsd.org/D12785
Notes:
svn path=/head/; revision=331945
|
|
|
|
|
|
|
|
|
|
|
|
| |
While I'm at it correct the update date in the man page.
Reported by: ed@
MFC after: 2 weeks
X-MFC with: r331936
Differential Revision: https://reviews.freebsd.org/D12785
Notes:
svn path=/head/; revision=331942
|