summaryrefslogtreecommitdiff
path: root/lib/libc/stdio
AgeCommit message (Collapse)Author
2016-08-29Store the return value of mbrtowc() in a size_t, not int.Todd C. Miller
OK schwarze@
2016-08-27Stop recommending the non-standard and slightly dangerous fgetln(3).Ingo Schwarze
Recommend POSIX getline(3) instead.
2016-08-27When a precision is specified for a string format use strnlen()Todd C. Miller
to determine the length instead of doing it manually. OK schwarze@
2016-08-27improve revision 1.2: in unusual cases, fgetwc(3) can succeedIngo Schwarze
even though ferror(3) is already set; also from Andrey Chernov <ache at freebsd dot org>; OK millert@
2016-08-25After read errors, fgetln(3) sometimes succeeded (returning non-NULL)Ingo Schwarze
and failed (setting errno and ferror(3)) both at the same time. That's a bad idea in general, and here in particular since returning partial lines was neither reliable (sometimes, you got NULL anyway) nor predictable (almost always, the line would be truncated long before the actual read error). Instead, on read failure, fail properly and always return NULL. Issue found in a discussion with Andrey Chernov <ache at freebsd dot org> who finally agreed to move FreeBSD into the same direction. The fix is joint work with and OK by millert@.
2016-08-24set the error indicator on malloc(3) failure;Ingo Schwarze
from Andrey Chernov <ache at freebsd dot org>; OK millert@
2016-08-21bugfix: when fgetwc(3) fails, fgetwln(3) must fail as well;Ingo Schwarze
OK jca@ martijn@ millert@
2016-08-17% is escaped with more %, not backslash.Ted Unangst
2016-08-17Generate syslog warnings for %s fmt strings NULL to "(null)" conversions.Theo de Raadt
Over time we can repair software which performs this non-standard behaviour, and fix bugs along the way. Let's first find out how bad the situation is by deploying this in snapshots. This type of logging is possible because OpenBSD syslog_r(3) -> sendsyslog(2) is side-effect free enough to be used in the bowels of libc. ok tedu
2016-06-06Add ERRORS section, from FreeBSD. OK tedu@Todd C. Miller
2016-06-06Return EOVERFLOW, not ENOMEM for overflow conditions to match POSIX.Todd C. Miller
2016-05-26fputs(3) now returns a non-negative number (as opposed to 0) on successfulTodd C. Miller
completion, just like puts(3). Found the hard way in portable code. OK jmc@
2016-05-23Make _fwalk and _cleanup completely internal to libcPhilip Guenther
ok deraadt@
2016-05-07Use a Thread Information Block in both single and multi-threaded programs.Philip Guenther
This stores errno, the cancelation flags, and related bits for each thread and is allocated by ld.so or libc.a. This is an ABI break from 5.9-stable! Make libpthread dlopen'able by moving the cancelation wrappers into libc and doing locking and fork/errno handling via callbacks that libpthread registers when it first initializes. 'errno' *must* be declared via <errno.h> now! Clean up libpthread's symbol exports like libc. On powerpc, offset the TIB/TCB/TLS data from the register per the ELF spec. Testing by various, particularly sthen@ and patrick@ ok kettenis@
2016-04-05Prefer _MUTEX_*LOCK over _THREAD_PRIVATE_MUTEX_*LOCK() when thread-specificPhilip Guenther
data isn't necessary. ok mpi@, ok&tweak natano@
2016-04-04get* can change *lineptr on failurePhilip Guenther
ok sthen@
2016-03-30for some time now mandoc has not required MLINKS to functionJason McIntyre
correctly - logically complete that now by removing MLINKS from base; authors need only to ensure there is an entry in NAME for any function/ util being added. MLINKS will still work, and remain for perl to ease upgrades; ok nicm (curses) bcook (ssl) ok schwarze, who provided a lot of feedback and assistance ok tb natano jung
2016-03-26fix typo: "prefer seek()" -> "prefer fseek()"Theo Buehler
ok deraadt@, stsp@
2016-03-20Currently we have about a 50/50 split over fcntl(n, F_GETFL [,0])Kenneth R Westerback
idioms. Adopt the more concise fcntl(n, F_GETFL) over fcntl(n, F_GETFL, 0) where it is obvious further investigation will not yield and even better way. Obviousness evaluation and ok guenther@
2016-03-15remind people rewind is seldom a good choiceMarc Espie
okay jmc@
2016-01-26When encoding fails in fputwc(3), set the error indicator as requiredIngo Schwarze
by POSIX and as FreeBSD, SunOS 10/11, and glibc also do it. Note that an enquiry to the Austin Group led to the conclusion that this change probably violates the C standard: C and POSIX unintentionally conflict. But the POSIX behaviour makes more sense (easier to write correct error handling code for it, and a lower risk that programs miss errors) and is much more widespread, and the Austin Group intends to approach the C committee in order to adjust the C standard. See: http://austingroupbugs.net/view.php?id=1022 While here, do not set errno a second time, wcrtomb(3) already did that, and it is required to do it by the standard. OK millert@ and tedu@, and jca@ no longer objects
2016-01-19remove a nop assignment that has been #if 0'd since 1996mmcc
ok millert@
2016-01-04Bugfix: When errno happens to be EILSEQ upon entry to fgetws(3),Ingo Schwarze
and when the file ends without a terminating Ln character, fgetws(3) discarded any characters read and reported bogus EOF. Never inspect errno(2) unless right after an error occurred! OK millert@
2016-01-04Fix lots of bugs.Ingo Schwarze
1. When fprintf(fp, "...%ls...", ...) encounters an encoding error, do not destroy all the fp->_flags, which made the file permanently unreadable and unwriteable. 2. Do not change fp->_flags at all in case of encoding errors. Neither the manual nor POSIX ask for it, no other conversions set the error indicator, and it isn't needed because the return value reports failure and must be checked anyway. 3. Detect failure in mbrtowc(3), do not silently treat invalid bytes in the format string as the end of the format string. 4. Detect failure of __find_arguments(), no matter whether due to out of memory conditions or encoding errors, and gracefully fail rather than accessing an invalid pointer. 5. Remove the pointless and slightly dangerous errno = EILSEQ overrides after functions that already do that and are required by the standard to do so. OK jca@ on items 1, 2, and 5. OK millert@ on the complete diff. "Completely brutal mix of bugs." deraadt@
2015-12-28Remove NULL-checks before free() and a few related dead assignments.mmcc
ok and valuable input from millert@
2015-12-24Both our manual and POSIX ask us to set the error indicator when anIngo Schwarze
encoding error occurs, so do it. While here, do not set errno after mbrtowc(3) failure; mbrtowc(3) already does that, and that behaviour is required by the standard. ok jca@ guenther@ "nice find" deraadt@
2015-11-04replace setbuf with setvbuf, from Frederic NowakTed Unangst
2015-10-25Hide __atexit and __atexit_register_cleanup()Philip Guenther
Wrap __cxa_{atexit,finalize}() so the call from exit() goes direct Switch regress/lib/libc/atexit/ to be built with -static so that it can still access __atexit* ok millert@ jca@
2015-10-13Sync printf family return value with ISO C which specifies thatTodd C. Miller
these functions return a negative value on failure. OK doug@ deraadt@
2015-10-07Be explicit that the user is responsible for freeing the line bufferTodd C. Miller
and show this in the example.
2015-10-04wrap _fwalk() so internal calls are direct (at least until we stopPhilip Guenther
exporting it)
2015-10-01Eliminate the last of the LINTEDn and PRINTFLIKEn comments. In onePhilip Guenther
case, by deleting some useless '& of an array' we also eliminate the need for the casts which prompted the original lint warnings ok deraadt@
2015-09-29Delete the final, inscrutable NOSTRICT and VARARGS lint commentsPhilip Guenther
ok millert@
2015-09-14in the SYNOPSIS, make void function arguments explicitIngo Schwarze
2015-09-14Wrap the remaining __*dtoa() functions so that internal calls go directPhilip Guenther
2015-09-13Wrap <stdlib.h> so that calls go direct and the symbols not in thePhilip Guenther
C standard are all weak. Apply __{BEGIN,END}_HIDDEN_DECLS to gdtoa{,imp}.h, hiding the arch-specific __strtorx, __ULtox_D2A, __strtorQ, __ULtoQ_D2A symbols.
2015-09-12Wrap <inttypes.h> and finish wrapping of <wchar.h> so that calls go directPhilip Guenther
and the symbols not in the C standard are weak
2015-09-12Wrap <unistd.h> so that internal calls go direct and they're all weak symbolsPhilip Guenther
Delete unused 'fd' argument from internal function oldttyname()
2015-09-10another missing MdocdateIngo Schwarze
2015-08-31Add framework for resolving (pun intended) libc namespace issues, usingPhilip Guenther
wrapper .h files and asm labels to let internal calls resolve directly and not be overridable or use the PLT. Then, apply that framework to most of the functions in stdio.h, string.h, err.h, and wchar.h. Delete the should-have-been-hidden-all-along _v?(err|warn)[cx]? symbols while here. tests clean on i386, amd64, sparc64, powerpc, and mips64 naming feedback from kettenis@ and millert@ ok kettenis@
2015-08-27Use static and __{BEGIN,ENV}_HIDDEN_DECLS to hide a bunch of internalPhilip Guenther
symbols that are not longer exported. (This improves the generated code.) ok deraadt@
2015-08-20All these files include <stdlib.h>, so do not need to castTheo de Raadt
malloc/calloc/realloc* returns.
2015-06-03snprintf(3) is available on all modern systems and asprintf(3) isTodd C. Miller
available on more systems these days. OK deraadt@
2015-03-23fix memory leaks in tempnam(3) error pathsJonathan Gray
ok miod@ millert@ krw@ guenther@
2015-03-13remove the first comma from constructs like ", and," and ", or,": you can useJason McIntyre
"and" and "or" to join sentence clauses, and you can use commas, but both hinders reading;
2015-03-12Fix typo: nemb -> nmembLawrence Teo
From Ryan May.
2015-03-05Revert; committed by accident without approval from deraadt@ at releaseLawrence Teo
time. Prodded by guenther@. Sorry.
2015-03-05Fix typo, from Ryan May.Lawrence Teo
2015-02-28Reduce usage of predefined strings in manpages.Anthony J. Bentley
Predefined strings are not very portable across troff implementations, and they make the source much harder to read. Usually the intended character can be written directly. No output changes, except for two instances where the incorrect escape was used in the first place. tweaks + ok schwarze@
2015-02-06SIZE_MAX is standard, we should be using it in preference to theTodd C. Miller
obsolete SIZE_T_MAX. OK miod@ beck@