summaryrefslogtreecommitdiff
path: root/lib/libc/stdio
Commit message (Collapse)AuthorAgeFilesLines
* MFC r204447:Jaakko Heinonen2010-03-191-0/+4
| | | | | | | | | | | In _gettemp(), check that the length of the path doesn't exceed MAXPATHLEN. Otherwise the path name (or part of it) may not fit to carrybuf causing a buffer overflow. PR: bin/140228 Notes: svn path=/stable/7/; revision=205330
* MFC r200799:Xin LI2010-01-201-8/+3
| | | | | | | K&R -> ANSI prototype. Notes: svn path=/stable/7/; revision=202667
* MFC: r201836Christian Brueffer2010-01-151-3/+2
| | | | | | | Remove unnecessary quoting and markup, add missing punctuation. Notes: svn path=/stable/7/; revision=202414
* MFC revs 199781,199782,199784,199786:Garrett Wollman2009-12-023-3/+3
| | | | | | | | | | | | | | | | | | | | Eliminate dead stores. In __mbsconv(), if prec was zero, nconv could have been used uninitialized. Initialize it to a safe value so that there's no chance of returning an error if stack garbage happens to be equal to (size_t)-1 or (size_t)-2. In clnt_raw_create(), avoid minor race condition initializing the file-scope variable clntraw_private. Mark head rev 199785 as merged; 7-STABLE's version of svc_raw_reply() doesn't have the same bug (or even look all that similar). Found by: Clang static analyzer Notes: svn path=/stable/7/; revision=200017
* Partial MFC of r189131:David Schultz2009-03-142-2/+2
| | | | | | | | | Make sure %zd treats negative arguments properly on 32-bit platforms. PR: 131880 Notes: svn path=/stable/7/; revision=189802
* MFC r186887:David Schultz2009-01-281-0/+1
| | | | | | | | | Set the error indicator on an attempt to write to a read-only stream. PR: 127335 Notes: svn path=/stable/7/; revision=187810
* MFC: Fix fread() to return a correct value on platforms where sizeof(int) !=Ruslan Ermilov2008-12-131-1/+1
| | | | | | | | | sizeof(size_t), i.e. on all 64-bit platforms. Approved by: re (kib) Notes: svn path=/stable/7/; revision=186042
* MFC r181281: Make swprintf("%s", "") not fail randomly depending onColin Percival2008-08-301-1/+3
| | | | | | | uninitialized variables. Notes: svn path=/stable/7/; revision=182495
* MFC: Fix a few bugs with the _gettemp() routine which implements mkstemp(),John Baldwin2008-08-041-11/+26
| | | | | | | mkstemps(), and mkdtemp(). Notes: svn path=/stable/7/; revision=181306
* MFC r178921 to stable/7:Antoine Brodin2008-07-281-4/+0
| | | | | | | | | | | | | Remove useless call to getdtablesize(2) in fdopen(3) and its useless variable nofile. PR: 123109 Submitted by: Christoph Mallon Approved by: rwatson (mentor) MFC after: 1 month Notes: svn path=/stable/7/; revision=180933
* MFC: Fix a resource leak in the recent fixes for file descriptors >John Baldwin2008-04-291-0/+1
| | | | | | | SHRT_MAX. Notes: svn path=/stable/7/; revision=178665
* MFC: Fail attempts to use file descriptors larger than SHRT_MAX.John Baldwin2008-03-173-0/+42
| | | | Notes: svn path=/stable/7/; revision=177307
* Add rewind() to the list of functions which may fail and set errnoAndrey A. Chernov2007-06-181-1/+2
| | | | Notes: svn path=/head/; revision=170908
* Add mbstate clear missed in one of the cases.Andrey A. Chernov2007-06-181-5/+6
| | | | | | | Move overflow check for fseek as early as needed. Notes: svn path=/head/; revision=170907
* We should never zero-pad INF or NaN (yielding silly strings like "00inf")David Schultz2007-05-081-0/+1
| | | | | | | even if the programmer asks for zero padding. Notes: svn path=/head/; revision=169355
* Use C comments since we now preprocess these files with CPP.Daniel Eischen2007-04-291-3/+5
| | | | Notes: svn path=/head/; revision=169092
* Grammer correction from: emastePoul-Henning Kamp2007-04-191-1/+1
| | | | Notes: svn path=/head/; revision=168862
* Loosen return value spec for fputs to be standards compliant so peoplePoul-Henning Kamp2007-04-191-5/+2
| | | | | | | don't program against our more restrictive behaviour. Notes: svn path=/head/; revision=168858
* o Add ENVIRONMENT section and mention there that TMPDIR is ignoredMaxim Konovalov2007-03-161-1/+14
| | | | | | | | | | | when issetugid(3) is true. PR: docs/108346 Obtained from: OpenBSD MFC after: 1 week Notes: svn path=/head/; revision=167652
* Remove 3rd clause, renumber, ok per emailWarner Losh2007-01-121-4/+1
| | | | Notes: svn path=/head/; revision=165968
* Per Regents of the University of Calfornia letter, remove advertisingWarner Losh2007-01-09100-400/+0
| | | | | | | | | clause. # If I've done so improperly on a file, please let me know. Notes: svn path=/head/; revision=165903
* Fix rounding of 0xf for hex fp formats.David Schultz2007-01-031-2/+2
| | | | | | | PR: 90333 Notes: svn path=/head/; revision=165742
* Revert the rev. 1.4, it causes breakage on most arches except i386.Konstantin Belousov2006-10-231-4/+1
| | | | | | | | | | | | Remove the const qualifier from ap argument for __v2printf, that induced that breakage, and seems to be the real reason for bad code. ap is modified inside the __v2printf body by va_arg macro. Pointy hat to: kib Approved by: pjd (mentor) Notes: svn path=/head/; revision=163624
* Workaround for (what seems to be) compiler error for gcc 3.4.6. OnKonstantin Belousov2006-10-211-1/+4
| | | | | | | | | | | | | | | | i386 with default optimization level (-O2), va_list pointer ap in the __v2printf function is advanced before the use. That cause argument shift and garbage instead last argument in printf-family when xprintf is activated. The nsswitch is easy victim of the bug. Reviewed by: kan Approved by: kan (mentor) MFC after: 1 week Notes: svn path=/head/; revision=163566
* file == NULL:Andrey A. Chernov2006-10-161-9/+14
| | | | | | | | | | | | | | | | Issue __sflush() before possible setting O_APPEND mode or ftruncate(), write to wrong place may occurse oserwise. Use simplified _sseek() to the start, if no O_APPEND is set, instead of _fseeko() (_sseek() to the end, if O_APPEND, occurse later, as for file != NULL). Don't check seek error return, as original fopen() and freopen() never does. file != NULL: Add missing _sseek() to the end. Notes: svn path=/head/; revision=163430
* Honor errno obtained from __sflagsAndrey A. Chernov2006-10-161-1/+3
| | | | | | | Move errno restoring after FUNLOCKFILE in one case Notes: svn path=/head/; revision=163406
* Back out ftruncate error handling. There can some file tipesAndrey A. Chernov2006-10-161-9/+2
| | | | | | | f.e. sockets when ftruncate normally fail. Notes: svn path=/head/; revision=163405
* Do real seekAndrey A. Chernov2006-10-151-3/+11
| | | | | | | | | | Catch ftruncate errors PR: 104295 Submitted by: ru (seek) Notes: svn path=/head/; revision=163385
* Use correct type in va_arg argument.Alexander Kabaev2006-09-212-2/+2
| | | | Notes: svn path=/head/; revision=162523
* Markup fixes.Ruslan Ermilov2006-09-171-1/+1
| | | | Notes: svn path=/head/; revision=162385
* Remove alpha left-overs.Ruslan Ermilov2006-08-221-1/+1
| | | | Notes: svn path=/head/; revision=161526
* Oops, correct the weak reference (s/fclose/fcloseall).Daniel Eischen2006-04-221-1/+1
| | | | | | | Spotted by: Antoine Brodin (antoine _dot_ brodin _at_ laposte _dot_ net) Notes: svn path=/head/; revision=157963
* Now that libc has fcloseall(), remove _cleanup() from the listDaniel Eischen2006-04-221-1/+0
| | | | | | | of FreeBSD private symbols. Notes: svn path=/head/; revision=157961
* Add fcloseall() to libc. This removes the need to export _cleanup().Daniel Eischen2006-04-225-4/+60
| | | | | | | | | Linux also provides an fcloseall() implementation. Discussed on: arch Notes: svn path=/head/; revision=157959
* Add missing #if's for NO_FLOATING_POINTPoul-Henning Kamp2006-04-015-4/+16
| | | | Notes: svn path=/head/; revision=157381
* Add __collate_load_error and __collate_range_cmp to the list ofDaniel Eischen2006-03-301-0/+1
| | | | | | | | | | | | | | | | FBSDprivate locale symbols. These functions are needed by libcompat. Add _cleanup to the list of stdio FBSDprivate symbols. Some third party applications use this. This will be removed and replaced by fcloseall() once libc version is bumped. Add _res to the list of resolv symbols. Found by: portbuilder runs (thanks Kris!) Notes: svn path=/head/; revision=157282
* Add each directory's symbol map file to SYM_MAPS.Daniel Eischen2006-03-131-0/+2
| | | | Notes: svn path=/head/; revision=156613
* Add symbol maps and initial symbol version definitions to libc.Daniel Eischen2006-03-131-0/+144
| | | | | | | Reviewed by: davidxu Notes: svn path=/head/; revision=156608
* Fix the %Q printf extension to behave as expectedPoul-Henning Kamp2006-03-021-19/+9
| | | | Notes: svn path=/head/; revision=156207
* Remove spurious "union arg" from printf.hPoul-Henning Kamp2006-02-041-2/+3
| | | | | | | Make sure to always print something in the alternate time format. Notes: svn path=/head/; revision=155300
* Add missing 's' suffix on alternate rendition of time.Poul-Henning Kamp2006-01-311-1/+1
| | | | Notes: svn path=/head/; revision=155085
* Make the %V{is} extension handle a NULL pointer like %s does: output "(null)"Poul-Henning Kamp2006-01-255-1/+187
| | | | | | | | | | | | | | | | Add %M{essage} extension which prints an errno value as the corresponding string if possible or numerically otherwise. It is not currently possible to do the syslog(3) like %m extension because errno would need to get capatured on entry to the first function in the printf family, so %M requires you to supply errno as an argument. Add %Q{uote} extension which will print a string in double quotes with appropriate back-slash escapes (only) if necessary. Notes: svn path=/head/; revision=154815
* Explicitely use a "signed char" instead of a "char", for those archs whereOlivier Houchard2005-12-221-2/+2
| | | | | | | char defaults to unsigned. Notes: svn path=/head/; revision=153641
* Add an extensible version of our *printf(3) implementation to libcPoul-Henning Kamp2005-12-169-0/+2054
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | on probationary terms: it may go away again if it transpires it is a bad idea. This extensible printf version will only be used if either environment variable USE_XPRINTF is defined or one of the extension functions are called. or the global variable __use_xprintf is set greater than zero. In all other cases our traditional printf implementation will be used. The extensible version is slower than the default printf, mostly because less opportunity for combining I/O operation exists when faced with extensions. The default printf on the other hand is a bad case of spaghetti code. The extension API has a GLIBC compatible part and a FreeBSD version of same. The FreeBSD version exists because the GLIBC version may run afoul of our FILE * locking in multithreaded programs and it even further eliminate the opportunities for combining I/O operations. Include three demo extensions which can be enabled if desired: time (%T), hexdump (%H) and strvis (%V). %T can format time_t (%T), struct timeval (%lT) and struct timespec (%llT) in one of two human readable duration formats: "%.3llT" -> "20349.245" "%#.3llT" -> "5h39m9.245" %H will hexdump a sequence of bytes and takes a pointer and a length argument. The width specifies number of bytes per line. "%4H" -> "65 72 20 65" "%+4H" -> "0000 65 72 20 65" "%#4H" -> "65 72 20 65 |er e|" "%+#4H" -> "0000 65 72 20 65 |er e|" %V will dump a string in strvis format. "%V" -> "Hello\tWor\377ld" (C-style) "%0V" -> "Hello\011Wor\377ld" (octal) "%+V" -> "Hello%09Wor%FFld" (http-style) Tests, comments, bugreports etc are most welcome. Notes: svn path=/head/; revision=153486
* With current pthread implementations, a mutex initialization willDavid Xu2005-12-163-9/+19
| | | | | | | | | | | | | | | allocate a memory block. sscanf calls __svfscanf which in turn calls fread, fread triggers mutex initialization but the mutex is not destroyed in sscanf, this leads to memory leak. To avoid the memory leak and performance issue, we create a none MT-safe version of fread: __fread, and instead let __svfscanf call __fread. PR: threads/90392 Patch submitted by: dhartmei MFC after: 7 days Notes: svn path=/head/; revision=153467
* /* You're not supposed to hit this problem */Poul-Henning Kamp2005-12-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For some denormalized long double values, a bug in __hldtoa() (called from *printf()'s %A format) results in a base 16 digit being rounded up from 0xf to 0x10. When this digit is subsequently converted to string format, an index of 10 reaches past the end of the uppper-case hex/char array, picking up whatever the code segment happen to contain at that address. This mostly seem to be some character from the upper half of the byte range. When using the %a format instead of %A, the first character past the end of the lowercase hex/char table happens to be index 0 in the uppercase hex/char table hextable and therefore the string representation features a '0', which is supposedly correct. This leads me to belive that the proper fix _may_ be as simple as masking all but the lower four bits off after incrementing a hex-digit in libc/gdtoa/_hdtoa.c:roundup(). I worry however that the upper bit in 0x10 indicates a carry not carried. Until das@ or bde@ finds time to visit this issue, extend the hexdigit arrays with a 17th index containing '?' so that we get a invalid but consistent and printable output in both %a and %A formats whenever this bug strikes. This unmasks the bug in the %a format therefore solving the real issue may both become easier and more urgent. Possibly related to: PR 85080 With help by: bde@ Notes: svn path=/head/; revision=153375
* Fix prototype.Ruslan Ermilov2005-11-232-2/+2
| | | | Notes: svn path=/head/; revision=152733
* Use the correct function name as .Nm argument.Christian Brueffer2005-09-181-1/+1
| | | | | | | | | PR: 86169 Submitted by: Toby Peterson <toby@apple.com> MFC after: 3 days Notes: svn path=/head/; revision=150291
* Move the declaration of __cleanup to libc_private.h as it is used in bothStefan Farfeleder2005-09-122-2/+3
| | | | | | | stdio/ and stdlib/. Don't define __cleanup twice. Notes: svn path=/head/; revision=150040
* Remove references to nonexistent "FreeBSD Security Architecture" document.Tim J. Robbins2005-09-053-15/+0
| | | | Notes: svn path=/head/; revision=149792