summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio
Commit message (Collapse)AuthorAgeFilesLines
* Fix a couple of markup typos.jhb2015-08-021-3/+3
| | | | MFC after: 2 weeks
* Add fdclose(3) function.oshogbo2015-07-043-27/+134
| | | | | | | | | | 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
* Reassign copyright statements on several files from Advancedjhb2015-04-233-3/+3
| | | | | | | Computing Technologies LLC to Hudson River Trading LLC. Approved by: Hudson River Trading LLC (who owns ACT LLC) MFC after: 1 week
* Support file verification in MAC.rodrigc2015-04-221-0/+4
| | | | | | | | | | | | | | * Add VCREAT flag to indicate when a new file is being created * Add VVERIFY to indicate verification is required * Both VCREAT and VVERIFY are only passed on the MAC method vnode_check_open and are removed from the accmode after * Add O_VERIFY flag to rtld open of objects * Add 'v' flag to __sflags to set O_VERIFY flag. Submitted by: Steve Kiernan <stevek@juniper.net> Obtained from: Juniper Networks, Inc. GitHub Pull Request: https://github.com/freebsd/freebsd/pull/27 Relnotes: yes
* libc: clean some set-but-not-used errors.pfg2015-02-181-3/+0
| | | | | | | These were found by gcc 5.0 on Dragonfly BSD, however I made no attempt to silence the false positives. Obtained from: DragonFly (cf515c3a6f3a8964ad592e524442bc628f8ed63b)
* In r268924 __fflush was modified so that when write(2) was not successful,delphij2014-12-101-4/+6
| | | | | | | | | | | | _p and _w are adjusted to account for the partial write (if any). However, _p and _w should not be unconditionally adjusted and should only be changed when we actually wrote some bytes, or the accumulated accounting error will eventually result in a heap buffer overflow. Reported by: adrian and alfred (Norse Corporation) Security: FreeBSD-SA-14:27.stdio Security: CVE-2014-8611
* Fix prototypes.kevlo2014-10-281-3/+3
|
* Fix the example: free the memory that was allocated by getline().n_hibma2014-07-311-0/+1
|
* In the "Too many open files" edge cases don't try to preserve oldache2014-07-261-0/+8
| | | | | | | number for non-std* descriptors, but close old file and retry. Obtained from: inspired by Apple's change from pfg@ MFC after: 2 weeks
* Avoid possible cast degradation.pfg2014-07-222-2/+2
| | | | | | | | | | | For consistency with r268985 for fputs.c, assign iov_len first, avoiding the cast to uio_resid (int in stdio) from degrading the value. We currently don't support lengths higher than INT_MAX so this change is little more than cosmetic. MFC after: 3 days
* For "a"-mode files and rewind/fseek + fwrite combination return meaningfulache2014-07-221-0/+18
| | | | | value now, like Apple does, but avoid their __sflush physical write performance degradation as much as possible.
* Back the whole change out until I figure out how to obtain O_APPEND,ache2014-07-221-6/+0
| | | | it can't be used in this field at all.
* Checking for __SAPP alone is not enough because it is emulated O_APPENDache2014-07-221-1/+2
| | | | only, so works for only special fdopen() case. Add real O_APPEND too.
* Revert r268984:pfg2014-07-221-2/+5
| | | | | | | | Check for __SAPP flag before calling sflush. This avoids performance degradation compared to the previous approach. Submitted by: ache MFC after: 2 weeks
* Mostly cosmetic cleanups.pfg2014-07-222-3/+3
| | | | | | In fputs() avoid implcit casting on iov.iov_len. MFC after: 3 days
* ftello: return 1 when seeking offset on an append stream.pfg2014-07-221-0/+2
| | | | | | Obtained from: Apple Inc. (Libc 997.90.3) Phabric: D442 MFC after: 2 weeks
* rewind: always clear error indicator.pfg2014-07-221-3/+2
| | | | | | | | Required by POSIX: http://pubs.opengroup.org/onlinepubs/009695399/functions/rewind.html Obtained from: Apple Inc. (Libc 997.90.3) MFC after: 1 week
* Adjust errno on failed prepwrite.pfg2014-07-203-3/+10
| | | | | | Obtained from: Apple Inc. (Libc 997.90.3) Phabric: D442 MFC after: 1 week
* Const-ify a character string.pfg2014-07-201-1/+1
| | | | | Obtained from: Apple Inc. (Libc 997.90.3) MFC after: 3 days
* Use a correct errno in freopen.pfg2014-07-201-1/+1
| | | | | | | | | Use EBADF instead of EINVAL when working around incorrect O_ACCMODE. Phabric: D442 Obtained from: Apple Inc. (Libc 997.90.3) Reviewed by: jilles MFC after: 1 week
* Update fflush(3) to return success on a read-only stream.pfg2014-07-201-9/+16
| | | | | | | | | | This has small changes to what Apple uses 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
* use .Mt to mark up email addresses consistently (part4)bapt2014-06-231-2/+2
| | | | | PR: 191174 Submitted by: Franco Fichtner <franco at lastsummer.de>
* - Return NULL and set errno to EINVAL if size is 0 (as required by POSIX).gahr2014-06-022-8/+18
| | | | | | | | | | 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
* libc/stdio: Fail fdopen() on an execute-only fd.jilles2014-04-212-3/+5
| | | | | | | | | An execute-only fd (opened with O_EXEC) allows neither read() nor write() and is therefore incompatible with all stdio modes. Therefore, the [EINVAL] error applies. Also adjust the similar check in freopen() with a NULL path, even though this checks an fd which is already from a FILE.
* libc man pages: Remove reference to non-existent FreeBSD Securityeadler2014-03-071-2/+0
| | | | | | Architecture MFC After: 3 days
* Replace use of ${.CURDIR} by ${LIBC_SRCTOP} and define ${LIBC_SRCTOP}marcel2014-03-041-2/+2
| | | | | | | | | | | if not already defined. This allows building libc from outside of lib/libc using a reach-over makefile. A typical use-case is to build a standard ILP32 version and a COMPAT32 version in a single iteration by building the COMPAT32 version using a reach-over makefile. Obtained from: Juniper Networks, Inc.
* Add missing include files for the printf_l and scanf_l man pages.eadler2013-11-172-0/+2
| | | | Reported by: swildner@dragonflybsd.org
* libc/stdio: Allow fopen/freopen modes in any order (except initial r/w/a).jilles2013-09-061-27/+28
| | | | | | | | | | 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.
* libc: Always use our own copy of sys_errlist and sys_nerr (.so only).jilles2013-08-311-1/+2
| | | | | | | | | | | | | | | 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.
* Add mkostemp() and mkostemps().jilles2013-08-094-21/+106
| | | | | These are like mkstemp() and mkstemps() but allow passing open(2) flags like O_CLOEXEC.
* Typo corrected.schweikh2013-07-121-1/+1
|
* mktemp(3): Add standards section. Prefer standard header.jilles2013-07-051-4/+29
| | | | | | 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.
* Convert libc/stdio from K&R to ANSI Cemaste2013-04-2334-151/+53
| | | | And add '__restrict' where it appeared in the header prototypes
* Renumber clauses to reduce diffs to other versionsemaste2013-04-2370-70/+70
| | | | | | | NetBSD, OpenBSD, and Android's Bionic all number the clauses 1 through 3, so follow suit to make comparison easier. Acked-by: imp@
* Spelling correctionemaste2013-04-111-1/+1
|
* Remove unused atomic headeremaste2013-04-111-1/+0
|
* mdoc: add missing El.joel2013-02-271-0/+1
|
* Add an implementation of open_memstream() and open_wmemstream(). Thesejhb2013-02-275-1/+639
| | | | | | | | | 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
* setbuf(3): Restore a BUGS section about setbuf().jilles2013-02-181-1/+4
| | | | | | | The brokenness of setbuf() is not specific to 4.2BSD and 4.3BSD but inherent in the API definition. Reported by: bde
* setbuf(3): Remove bugs section about ancient versions of BSD.jilles2013-02-151-17/+1
|
* mdoc: Remove EOL whitespace.joel2013-02-091-1/+1
|
* - Fix more style(9)-related issues (copyright header, spaces after functiongahr2013-02-011-56/+55
| | | | | | | | | names, unnecessary casts) - Change type of boolean variable from char to bool Suggested by: jhb, zont, jmallett Reviewed by: cognet Approved by: cognet
* - Remove underscores from the internal structure name, as it doesn't collidegahr2013-01-312-32/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add fmemopen(3), an interface to get a FILE * from a buffer in memory, alonggahr2013-01-304-7/+224
| | | | | | | | with the respective regression test. See http://pubs.opengroup.org/onlinepubs/9699919799/functions/fmemopen.html Reviewed by: cognet Approved by: cognet
* The getline function returns the number of characters read, noteadler2012-12-011-2/+2
| | | | | | | | | written. Use clearer text for this. PR: docs/174023 Submitted by: Paul Procacci <pprocacci@gmail.com> Approved by: bcr (mentor) MFC after: 1 week
* libc: Allow setting close-on-exec in fopen/freopen/fdopen.jilles2012-11-304-2/+33
| | | | | | | | | | | | | | | | | | | 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
* Clarify that the ' flag is an apostrophe.grog2012-11-081-1/+1
| | | | MFC after: 2 weeks
* fopen(3): Mention that the "x" mode option is from C11.jilles2012-11-011-1/+5
| | | | MFC after: 1 week
* Correct double "the the"eadler2012-09-141-1/+1
| | | | | Approved by: cperciva MFC after: 3 days
* The register_printf_render_std() function expects regular string.pjd2012-07-041-1/+1
| | | | | | Change argument type from 'const unsigned char *' to 'const char *'. MFC after: 2 weeks
OpenPOWER on IntegriCloud