summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio
Commit message (Collapse)AuthorAgeFilesLines
* MFC r318705:ngie2017-07-181-5/+10
| | | | | | | | fopen(3): make manlint fixes - Break on new lines. - Use .Dv with NULL. - Rewrap lines as necessary/when possible.
* MFC r320472,r320508,r320509:kib2017-07-1738-139/+186
| | | | | | Make stdio deferred cancel-safe. Requested by: eugen
* MFC r305413ache2016-09-081-4/+10
| | | | Fix error handling.
* MFC r305406,r305409,r305412ache2016-09-081-9/+25
| | | | | | | | | | | | | 1) Fix errors handling. 2) Prevent out of bounds access to ws[-1] (passed buffer) which happens when the first mb sequence is incomplete and there are not enougn chars in the read buffer. ws[-1] may lead to memory faults or false results, in case the memory here contains '\n'. 3) Fix n == 1 case. Here should be no physical read (fill buffer) attempt (we read n - 1 chars with the room for NUL, see fgets()), and no NULL return.
* MFC r305241ache2016-09-051-1/+11
| | | | | | | fgetwc(3) may set both __SEOF and __SERR at once (in case of incomplete sequence near EOF), so we can't just check for (wc == WEOF && !__sfeof(fp)) and must relay on __sferror(fp) with __SERR clearing/restoring.
* MFC r305219ache2016-09-041-5/+8
| | | | | If error happens, don't overwrite original errno comes from __mbrtowc() and __srefill().
* MFC r304607,r304641,r304819,r304811ache2016-08-274-28/+15
| | | | | | | | | | | | | | | | | 1) Don't forget to set __SERR on __slbexpand() error. 2) Remove "Fast path" from fgetwc()/fputwc() since it can't detect encoding errors and ignores them all. One of affected encoding example: US-ASCII 3) Original fgetln() from 44lite return success for line tail errors, i.e. partial line, but set __SERR and errno in the same time, which is inconsistent. Now both OpenBSD and NetBSD return failure, i.e. no line and set error indicators for such case, so make our fgetln() and fgetwln() (as its wide version) compatible with the rest of *BSD. PR: 212033
* MFC r304810ache2016-08-273-2/+14
| | | | | | | | Don't check for __SERR which may stick from one of any previous stdio functions. __SERR is for user and the rest of stdio code do not check it for error sensing internally, only set it. In vf(w)printf.c here it is more easy to save __SERR, clear and restore it.
* MFC r295632ache2016-08-252-2/+11
| | | | | | | | | | getln: We cannot expand the buffer beyond INT_MAX (_size overflows). In such cases return ENOMEM. This is a limitation of our implementation, alternatively you may consider getline(3). Differential Revision: https://reviews.freebsd.org/D442 (Partial) Obtained from: Apple Inc. (Libc 997.90.3)
* Direct commit, equal to MFC part of r295632 which is not planned forache2016-08-231-0/+1
| | | | | MFC at whole. Set __SERR on __slbexpand() errors.
* MFC: r302824ache2016-07-221-3/+3
| | | | | | | | | | | | | 1) Eliminate possibility to call __*collate_range_cmp() with inclomplete locale (which cause core dump) by removing whole 'table' argument by which it passed. 2) Restore __collate_range_cmp() in __sccl(). 3) Collating [a-z] range in regcomp() works for single byte locales only (we can't do it for other ones). In previous state only first 256 wide chars are considered and all others are just silently dropped from the range.
* MFH (r291197): markup fixesdes2016-01-261-3/+9
|
* MFC r292013:ngie2015-12-132-4/+4
| | | | | | | Use stdint.h instead of inttypes.h as the latter pollutes namespace more Submitted by: bde Sponsored by: EMC / Isilon Storage Division
* MFC r292004:ngie2015-12-132-0/+6
| | | | | | | | | | Fix compilation when -DDEBUG is defined by adding inttypes.h #include for intmax_t Differential Revision: https://reviews.freebsd.org/D4434 Reported by: cppcheck Reviewed by: jhb Sponsored by: EMC / Isilon Storage Division
* MFC r285140:ngie2015-12-013-27/+134
| | | | | | | | | | | | | | r285140 (by oshogbo): Add fdclose(3) function. 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
* MFC r278932:ngie2015-12-011-3/+0
| | | | | | | | | | | r278932 (by pfg): libc: clean some set-but-not-used errors. These were found by gcc 5.0 on Dragonfly BSD, however I made no attempt to silence the false positives. Obtained from: DragonFly (cf515c3a6f3a8964ad592e524442bc628f8ed63b)
* MFC r269326:ngie2015-12-011-0/+1
| | | | | | r269326 (by n_hibma): Fix the example: free the memory that was allocated by getline().
* MFC r288006,r288031,r288032,r288033:ngie2015-11-255-7/+11
| | | | | | | | | | | | | | | | | | r288006 (by rodrigc): Add declarations to eliminate -Wmissing-prototypes warnings r288031 (by rodrigc): Remove names from some prototypes r288032 (by rodrigc): Remove names from some prototypes r288033 (by rodrigc): Use ANSI C prototypes. Eliminates -Wold-style-definition warnings.
* MFC r258245:ngie2015-11-252-0/+2
| | | | | | | | r258245 (by eadler): Add missing include files for the printf_l and scanf_l man pages. Reported by: swildner@dragonflybsd.org
* MFC r264737:ngie2015-11-252-3/+5
| | | | | | | | | | | | | | | Discussed with: jilles r264737 (by jilles): libc/stdio: Fail fdopen() on an execute-only fd. 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.
* MFC: r290549,r290729ache2015-11-191-22/+7
| | | | | | | | | | | | | | r290549: Reorganize code to elimitate one _sseek() call for append modes. r290729: 1) Remove my overcomplicated error fallback and just return error 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: r289863,r289931,r290110,r290230,r290231,r290232ache2015-11-087-23/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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().
* MFC 286177:jhb2015-10-011-3/+3
| | | | Fix a couple of markup typos.
* MFC r287292:kib2015-09-051-3/+4
| | | | | | | | | | 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.
* MFC 281887:jhb2015-06-023-3/+3
| | | | | Reassign copyright statements on several files from Advanced Computing Technologies LLC to Hudson River Trading LLC.
* MFC discussed with: jilles, -developersngie2015-01-112-8/+18
| | | | | | | | | | | | | 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
* MFC r275665:delphij2014-12-101-4/+6
| | | | | | | Fix buffer overflow in stdio. Security: FreeBSD-SA-14:27.stdio Security: CVE-2014-8611
* MFC r273760:kevlo2014-11-241-3/+3
| | | | Fix prototypes.
* MFC r268924:pfg2014-08-161-9/+16
| | | | | | | | | | | 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
* MFC: r269116ache2014-08-061-0/+8
| | | | | | | 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@
* MFC: r268997ache2014-08-061-0/+18
| | | | | | 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.
* MFC r268926, r268930, r268983:pfg2014-08-035-7/+13
| | | | | | | | | | | | 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
* MFC r268985, r269001:pfg2014-07-254-5/+5
| | | | | | | | | 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.
* MFC r268928:pfg2014-07-231-1/+1
| | | | | | Const-ify a character string. Obtained from: Apple Inc. (Libc 997.90.3)
* MFC r262890:eadler2014-03-101-2/+0
| | | | | libc man pages: Remove reference to non-existent FreeBSD Security Architecture
* 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
OpenPOWER on IntegriCloud