| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
r290232:
Microoptimize.
r290231:
Addition to prev. commit.
In some edge cases fp->_p can be changed in _sseek(), recalculate.
r290230:
Don't seek to the end if write buffer is empty (in append modes).
PR: 204156
r290110:
Add _flags2 per jhb@ suggestion since no room left in _flags.
Rewrite O_APPEND flag checking using new __S2OAP flag.
r289931:
According to POSIX, a write operation shall start at the current size of
the stream (if mode had 'a' as the first character).
r289863:
Since no room left in the _flags, reuse __SALC for O_APPEND.
It helps to remove _fcntl() call from _ftello() and optimize seek position
calculation in _swrite().
|
|
|
|
| |
Fix a couple of markup typos.
|
|
|
|
|
|
|
|
|
|
| |
Switch libc from using _sig{procmask,action,suspend} symbols, which
are aliases for the syscall stubs and are plt-interposed, to the
libc-private aliases of internally interposed sigprocmask() etc.
MFC r287300:
Use libthr interposed functions instead of syscalls, in posix_spawn()'
child.
|
|
|
|
|
| |
Reassign copyright statements on several files from Advanced
Computing Technologies LLC to Hudson River Trading LLC.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
MFC r266971:
- Return NULL and set errno to EINVAL if size is 0 (as required by POSIX).
Update the manpage to reflect this change.
- Always set the current position to the first null-byte when opening in append
mode. This makes the implementation compatible with glibc's. Update the test
suite.
Reported by: pho
Approved by: cognet
|
|
|
|
|
|
|
| |
Fix buffer overflow in stdio.
Security: FreeBSD-SA-14:27.stdio
Security: CVE-2014-8611
|
|
|
|
| |
Fix prototypes.
|
|
|
|
|
|
|
|
|
|
|
| |
Update fflush(3) to return success on a read-only stream.
This is done for compliance with SUSv3. The changes cause
no secondary effects in the gnulib tests (we pass them).
Obtained from: Apple Inc. (Libc 997.90.3 with changes)
Reviewed by: bde
Phabric: D440
|
|
|
|
|
|
|
| |
In the "Too many open files" edge cases don't try to preserve old
number for non-std* descriptors, but close old file and retry.
Obtained from: inspired by Apple's change from pfg@
|
|
|
|
|
|
| |
For "a"-mode files and rewind/fseek + fwrite combination return meaningful
value now, like Apple does, but avoid their __sflush physical write
performance degradation as much as possible.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Use a correct errno in freopen.
Use EBADF instead of EINVAL when working around incorrect O_ACCMODE.
Adjust errno on failed prepwrite.
rewind: always clear error indicator as required by POSIX.
Obtained from: Apple Inc. (Libc 997.90.3)
Phabric: D442
|
|
|
|
|
|
|
|
|
| |
Avoid possible cast degradation.
Assign iov_len first, avoiding the cast to uio_resid
(int in stdio) from degrading the value.
Small cosmetical fix while here.
|
|
|
|
|
|
| |
Const-ify a character string.
Obtained from: Apple Inc. (Libc 997.90.3)
|
|
|
|
|
| |
libc man pages: Remove reference to non-existent FreeBSD Security
Architecture
|
|
|
|
|
|
|
|
|
|
| |
Austin Group issue #411 requires 'e' to be accepted before and after 'x',
and encourages accepting the characters in any order, except the initial
'r', 'w' or 'a'.
Given that glibc accepts the characters after r/w/a in any order and that
diagnosing this problem may be hard, change our libc to behave that way as
well.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This ensures strerror() and friends continue to work correctly even if a
(non-PIE) executable linked against an older libc imports sys_errlist (which
causes sys_errlist to refer to the executable's copy with a size fixed when
that executable was linked).
The executable's use of sys_errlist remains broken because it uses the
current value of sys_nerr and may access past the bounds of the array.
Different from the message "Using sys_errlist from executables is not
ABI-stable" on freebsd-arch, this change does not affect the static library.
There seems no reason to prevent overriding the error messages in the static
library.
|
|
|
|
|
| |
These are like mkstemp() and mkstemps() but allow passing open(2) flags like
O_CLOEXEC.
|
| |
|
|
|
|
|
|
| |
mktemp(), mkstemp() and mkdtemp() are available in standard <stdlib.h> and
also in <unistd.h>. Encourage use of the former by listing it in the
synopsis.
|
|
|
|
| |
And add '__restrict' where it appeared in the header prototypes
|
|
|
|
|
|
|
| |
NetBSD, OpenBSD, and Android's Bionic all number the clauses 1 through 3,
so follow suit to make comparison easier.
Acked-by: imp@
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
routines provide write-only stdio FILE objects that store their data in a
dynamically allocated buffer. They are a string builder interface somewhat
akin to a completely dynamic sbuf.
Reviewed by: bde, jilles (earlier versions)
MFC after: 1 month
|
|
|
|
|
|
|
| |
The brokenness of setbuf() is not specific to 4.2BSD and 4.3BSD but inherent
in the API definition.
Reported by: bde
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
names, unnecessary casts)
- Change type of boolean variable from char to bool
Suggested by: jhb, zont, jmallett
Reviewed by: cognet
Approved by: cognet
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
with the user's namespace.
- Correct size and position variables type from long to size_t.
- Do not set errno to ENOMEM on malloc failure, as malloc already does so.
- Implement the concept of "buffer data length", which mandates what SEEK_END
refers to and the allowed extent for a read.
- Use NULL as read-callback if the buffer is opened in write-only mode.
Conversely, use NULL as write-callback when opened in read-only mode.
- Implement the handling of the ``b'' character in the mode argument. A binary
buffer differs from a text buffer (default mode if ``b'' is omitted) in that
NULL bytes are never appended to writes and that the "buffer data length"
equals to the size of the buffer.
- Remove shall from the man page. Use indicative instead. Also, specify that
the ``b'' flag does not conform with POSIX but is supported by glibc.
- Update the regression test so that the ``b'' functionality and the "buffer
data length" concepts are tested.
- Minor style(9) corrections.
Suggested by: jilles
Reviewed by: cognet
Approved by: cognet
|
|
|
|
|
|
|
|
| |
with the respective regression test.
See http://pubs.opengroup.org/onlinepubs/9699919799/functions/fmemopen.html
Reviewed by: cognet
Approved by: cognet
|
|
|
|
|
|
|
|
|
| |
written. Use clearer text for this.
PR: docs/174023
Submitted by: Paul Procacci <pprocacci@gmail.com>
Approved by: bcr (mentor)
MFC after: 1 week
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit adds a new mode option 'e' that must follow any 'b', '+' and/or
'x' options. C11 is clear about the 'x' needing to follow 'b' and/or '+' and
that is what we implement; therefore, require a strict position for 'e' as
well.
For freopen() with a non-NULL path argument and fopen(), the close-on-exec
flag is set iff the 'e' mode option is specified. For freopen() with a NULL
path argument and fdopen(), the close-on-exec flag is turned on if the 'e'
mode option is specified and remains unchanged otherwise.
Although the same behaviour for fopen() can be obtained by open(O_CLOEXEC)
and fdopen(), this needlessly complicates the calling code.
Apart from the ordering requirement, the new option matches glibc.
PR: kern/169320
|
|
|
|
| |
MFC after: 2 weeks
|
|
|
|
| |
MFC after: 1 week
|
|
|
|
|
| |
Approved by: cperciva
MFC after: 3 days
|
|
|
|
|
|
| |
Change argument type from 'const unsigned char *' to 'const char *'.
MFC after: 2 weeks
|
|
|
|
|
|
|
|
|
|
| |
this fflush may fail to write data in the buffer.
PR: kern/137819
Submitted by: Eric Blake <ebb9@byu.net>
Reviewed by: theraven
Approved by: cperciva
MFC after: 2 weeks
|
|
|
|
|
|
|
|
|
| |
- libc/stdio/scanf_l.3
- libc/stdio/printf_l.3
Reviewed by: theraven
Approved by: gabor (mentor)
MFC after: 5 days
|
| |
|
|
|
|
|
| |
Approved by: cperciva
MFC after: 3 days
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The typical case was:
static __inline int
convert_ccl(FILE *fp, char * __restrict p, [...])
{
[...]
if (p == SUPPRESS_PTR) {
[...]
} else {
[...]
}
[...]
}
This qualifier says that the pointer is the only one at that time
pointing to the resource.
Here, clang considers that "p" will never match "SUPPRESS_PTR" and
optimize the if{} block out. This leads to segfaults in programs calling
vfscanf(3) and vfwscanf(3) with just the format string (no arguments
following it).
The following softwares were reported to abort with segmentation fault
and this patch fixes it:
o cmake
o smartd
o devel/ORBit2
dim@ opened an LLVM PR to discuss this clang optimization:
http://llvm.org/bugs/show_bug.cgi?id=12656
Tested by: bsam@
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
conversions. Both the specification and the documentation say the
width is interpreted as the max number of wide characters to read, but
the implementation was interpreting it as the number of bytes to convert.
(See also r105317.)
This change has security implications for any applications that depend
on the buggy behavior, but the impact in practice is probably nil.
Any such application would already be buggy on other platforms that
get the semantics right. Also, these conversions are rarely used;
%ls, %lc, and %l[ are more appropriate.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
reading wide characters manually. With this change, they now use
fgetwc(). To make this work, we use an internal version of fgetwc()
with a few extensions: it takes an mbstate * because non-wide streams
don't have a built-in mbstate, and it indicates the number of bytes
read.
vfscanf() now resembles vfwscanf() more closely. Minor functional
improvements include working xlocale support in vfscanf(), setting the
stream error indicator on encoding errors, and proper handling of
shift-based encodings. (Actually, making shift-based encodings work
with non-wide streams is hopeless, but the implementation now matches
the broken specification.)
|
|
|
|
|
| |
Submitted by: brueffer
Approved by: kib (mentor)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This tool changes the default buffering behaviour of standard
stdio streams.
It only works on dynamic binaries. To make it work for static
ones it would require cluttering stdio because there no single
entry point.
PR: 166660
Reviewed by: current@, jhb
Approved by: kib (mentor)
MFC after: 1 week
|
|
|
|
|
|
|
|
|
| |
indicates the avaliability of FILE, to prevent possible reordering of
the writes as seen by other CPUs.
Reported by: Fengwei yin <yfw.bsd gmail com>
Reviewed by: jhb
MFC after: 1 week
|
|
|
|
| |
characters read.
|
| |
|
|
|
|
| |
sscanf("abc", "ab%ncd", &i) returns EOF, not 0.
|