summaryrefslogtreecommitdiff
path: root/lib/libc/stdio
Commit message (Collapse)AuthorAgeFilesLines
* MFC r329848:Pedro F. Giffuni2018-02-281-2/+2
| | | | | | | | | | | | __printf_render_int(): small type change to match use. Variable l is consistently used as an int rather than a char. Sort names while here. Obtained from: Apple's Libc-1244.30.3 Notes: svn path=/stable/10/; revision=330097
* MFC r325030:Cy Schubert2017-11-041-1/+0
| | | | | | | Remove redundant sys/cdefs.h include. Notes: svn path=/stable/10/; revision=325381
* MFC r318705:Enji Cooper2017-07-181-5/+10
| | | | | | | | | | | fopen(3): make manlint fixes - Break on new lines. - Use .Dv with NULL. - Rewrap lines as necessary/when possible. Notes: svn path=/stable/10/; revision=321120
* MFC r320472,r320508,r320509:Konstantin Belousov2017-07-1738-139/+186
| | | | | | | | | Make stdio deferred cancel-safe. Requested by: eugen Notes: svn path=/stable/10/; revision=321074
* MFC r305413Andrey A. Chernov2016-09-081-4/+10
| | | | | | | Fix error handling. Notes: svn path=/stable/10/; revision=305583
* MFC r305406,r305409,r305412Andrey A. Chernov2016-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. Notes: svn path=/stable/10/; revision=305577
* MFC r305241Andrey A. Chernov2016-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. Notes: svn path=/stable/10/; revision=305403
* MFC r305219Andrey A. Chernov2016-09-041-5/+8
| | | | | | | | If error happens, don't overwrite original errno comes from __mbrtowc() and __srefill(). Notes: svn path=/stable/10/; revision=305369
* MFC r304607,r304641,r304819,r304811Andrey A. Chernov2016-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 Notes: svn path=/stable/10/; revision=304893
* MFC r304810Andrey A. Chernov2016-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. Notes: svn path=/stable/10/; revision=304888
* MFC r295632Andrey A. Chernov2016-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) Notes: svn path=/stable/10/; revision=304816
* Direct commit, equal to MFC part of r295632 which is not planned forAndrey A. Chernov2016-08-231-0/+1
| | | | | | | | MFC at whole. Set __SERR on __slbexpand() errors. Notes: svn path=/stable/10/; revision=304648
* MFC: r302824Andrey A. Chernov2016-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. Notes: svn path=/stable/10/; revision=303185
* MFH (r291197): markup fixesDag-Erling Smørgrav2016-01-261-3/+9
| | | | Notes: svn path=/stable/10/; revision=294781
* MFC r292013:Enji Cooper2015-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 Notes: svn path=/stable/10/; revision=292150
* MFC r292004:Enji Cooper2015-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 Notes: svn path=/stable/10/; revision=292140
* MFC r285140:Enji Cooper2015-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 Notes: svn path=/stable/10/; revision=291602
* MFC r278932:Enji Cooper2015-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) Notes: svn path=/stable/10/; revision=291573
* MFC r269326:Enji Cooper2015-12-011-0/+1
| | | | | | | | | r269326 (by n_hibma): Fix the example: free the memory that was allocated by getline(). Notes: svn path=/stable/10/; revision=291572
* MFC r288006,r288031,r288032,r288033:Enji Cooper2015-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. Notes: svn path=/stable/10/; revision=291336
* MFC r258245:Enji Cooper2015-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 Notes: svn path=/stable/10/; revision=291294
* MFC r264737:Enji Cooper2015-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. Notes: svn path=/stable/10/; revision=291293
* MFC: r290549,r290729Andrey A. Chernov2015-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. Notes: svn path=/stable/10/; revision=291050
* MFC: r289863,r289931,r290110,r290230,r290231,r290232Andrey A. Chernov2015-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(). Notes: svn path=/stable/10/; revision=290544
* MFC 286177:John Baldwin2015-10-011-3/+3
| | | | | | | Fix a couple of markup typos. Notes: svn path=/stable/10/; revision=288464
* MFC r287292:Konstantin Belousov2015-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. Notes: svn path=/stable/10/; revision=287480
* MFC 281887:John Baldwin2015-06-023-3/+3
| | | | | | | | Reassign copyright statements on several files from Advanced Computing Technologies LLC to Hudson River Trading LLC. Notes: svn path=/stable/10/; revision=283927
* MFC discussed with: jilles, -developersEnji Cooper2015-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 Notes: svn path=/stable/10/; revision=277016
* MFC r275665:Xin LI2014-12-101-4/+6
| | | | | | | | | | Fix buffer overflow in stdio. Security: FreeBSD-SA-14:27.stdio Security: CVE-2014-8611 Notes: svn path=/stable/10/; revision=275667
* MFC r273760:Kevin Lo2014-11-241-3/+3
| | | | | | | Fix prototypes. Notes: svn path=/stable/10/; revision=274943
* MFC r268924:Pedro F. Giffuni2014-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 Notes: svn path=/stable/10/; revision=270035
* MFC: r269116Andrey A. Chernov2014-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@ Notes: svn path=/stable/10/; revision=269624
* MFC: r268997Andrey A. Chernov2014-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. Notes: svn path=/stable/10/; revision=269623
* MFC r268926, r268930, r268983:Pedro F. Giffuni2014-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 Notes: svn path=/stable/10/; revision=269482
* MFC r268985, r269001:Pedro F. Giffuni2014-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. Notes: svn path=/stable/10/; revision=269085
* MFC r268928:Pedro F. Giffuni2014-07-231-1/+1
| | | | | | | | | Const-ify a character string. Obtained from: Apple Inc. (Libc 997.90.3) Notes: svn path=/stable/10/; revision=269007
* MFC r262890:Eitan Adler2014-03-101-2/+0
| | | | | | | | libc man pages: Remove reference to non-existent FreeBSD Security Architecture Notes: svn path=/stable/10/; revision=262965
* libc/stdio: Allow fopen/freopen modes in any order (except initial r/w/a).Jilles Tjoelker2013-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. Notes: svn path=/head/; revision=255303
* libc: Always use our own copy of sys_errlist and sys_nerr (.so only).Jilles Tjoelker2013-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. Notes: svn path=/head/; revision=255108
* Add mkostemp() and mkostemps().Jilles Tjoelker2013-08-094-21/+106
| | | | | | | | These are like mkstemp() and mkstemps() but allow passing open(2) flags like O_CLOEXEC. Notes: svn path=/head/; revision=254151
* Typo corrected.Jens Schweikhardt2013-07-121-1/+1
| | | | Notes: svn path=/head/; revision=253277
* mktemp(3): Add standards section. Prefer standard header.Jilles Tjoelker2013-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. Notes: svn path=/head/; revision=252838
* Convert libc/stdio from K&R to ANSI CEd Maste2013-04-2334-151/+53
| | | | | | | And add '__restrict' where it appeared in the header prototypes Notes: svn path=/head/; revision=249810
* Renumber clauses to reduce diffs to other versionsEd Maste2013-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@ Notes: svn path=/head/; revision=249808
* Spelling correctionEd Maste2013-04-111-1/+1
| | | | Notes: svn path=/head/; revision=249381
* Remove unused atomic headerEd Maste2013-04-111-1/+0
| | | | Notes: svn path=/head/; revision=249360
* mdoc: add missing El.Joel Dahl2013-02-271-0/+1
| | | | Notes: svn path=/head/; revision=247415
* Add an implementation of open_memstream() and open_wmemstream(). TheseJohn Baldwin2013-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 Notes: svn path=/head/; revision=247411
* setbuf(3): Restore a BUGS section about setbuf().Jilles Tjoelker2013-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 Notes: svn path=/head/; revision=246952
* setbuf(3): Remove bugs section about ancient versions of BSD.Jilles Tjoelker2013-02-151-17/+1
| | | | Notes: svn path=/head/; revision=246824