summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio
Commit message (Collapse)AuthorAgeFilesLines
* Use __alignof__ instead of assuming int64_t to get the rightimp2015-12-301-10/+1
| | | | | | alignment. Differential Revision: https://reviews.freebsd.org/D4708
* The FILE structure has a mbstate_t in it. This structure needs to beimp2015-12-271-2/+14
| | | | | | | | | | aligned on a int64_t boundary. However, when we allocate the array of these structures, we use ALIGNBYTES which defaults to sizeof(int) on arm, i386 and others. The i386 stuff can handle unaligned accesses seemlessly. However, arm cannot. Take this into account when creating the array of FILEs, and add some comments about why. Differential Revision: https://reviews.freebsd.org/D4708
* Use stdint.h instead of inttypes.h as the latter pollutes namespace morengie2015-12-092-4/+4
| | | | | | | MFC after: 3 days X-MFC with: r292004 Submitted by: bde Sponsored by: EMC / Isilon Storage Division
* Fix compilation when -DDEBUG is defined by adding inttypes.h #includengie2015-12-082-0/+6
| | | | | | | | | | for intmax_t MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D4434 Reported by: cppcheck Reviewed by: jhb Sponsored by: EMC / Isilon Storage Division
* Link fclose(3) to fdclose(3)ngie2015-11-251-1/+1
| | | | | | X-MFC with: r285140 MFC after: 3 weeks (need to evaluate whether or not r285140 can be MFCed) Sponsored by: EMC / Isilon Storage Division
* markup fixesdes2015-11-231-3/+9
|
* 1) Remove my overcomplicated error fallback and just return errorache2015-11-121-11/+3
| | | | | | | | | immediatelly as old code does, now for append modes too. Real use case for such fallback is impossible (unless specially crafted). 2) Remove now unneded include I forgot to remove in prev. commits. MFC after: 1 week
* Reorganize code to elimitate one _sseek() call for append modes.ache2015-11-081-21/+14
| | | | MFC after: 1 week
* Microoptimize.ache2015-11-011-4/+3
|
* Addition to prev. commit.ache2015-11-011-4/+6
| | | | | | | In some edge cases fp->_p can be changed in _sseek(), recalculate. PR: 204156 MFC after: 1 week
* Don't seek to the end if write buffer is empty (in append modes).ache2015-11-011-11/+12
| | | | | PR: 204156 MFC after: 1 week
* Add _flags2 per jhb@ suggestion since no room left in _flags.ache2015-10-286-10/+7
| | | | | | Rewrite O_APPEND flag checking using new __S2OAP flag. MFC after: 3 weeks
* According to POSIX, a write operation shall start at the current size ofache2015-10-251-0/+3
| | | | | | the stream (if mode had 'a' as the first character). MFC after: 1 week
* Since no room left in the _flags, reuse __SALC for O_APPEND.ache2015-10-245-19/+31
| | | | | | | It helps to remove _fcntl() call from _ftello() and optimize seek position calculation in _swrite(). MFC after: 3 weeks
* Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.rodrigc2015-09-203-8/+6
|
* Remove names from some prototypesrodrigc2015-09-201-1/+1
|
* Remove names from some prototypesrodrigc2015-09-201-2/+2
|
* Add declarations to eliminate -Wmissing-prototypes warningsrodrigc2015-09-203-0/+6
|
* Switch libc from using _sig{procmask,action,suspend} symbols, whichkib2015-08-291-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | are aliases for the syscall stubs and are plt-interposed, to the libc-private aliases of internally interposed sigprocmask() etc. Since e.g. _sigaction is not interposed by libthr, calling signal() removes thr_sighandler() from the handler slot etc. The result was breaking signal semantic and rtld locking. The added __libc_sigprocmask and other symbols are hidden, they are not exported and cannot be called through PLT. The setjmp/longjmp functions for x86 were changed to use direct calls, and since PIC_PROLOGUE only needed for functional PLT indirection on i386, it is removed as well. The PowerPC bug of calling the syscall directly in the setjmp/longjmp implementation is kept as is. Reported by: Pete French <petefrench@ingresso.co.uk> Tested by: Michiel Boland <boland37@xs4all.nl> Reviewed by: jilles (previous version) Sponsored by: The FreeBSD Foundation MFC after: 1 week
* 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
|
OpenPOWER on IntegriCloud