| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Largely considered attack surface nowadays. The benefit provided by %n
is completely overshadowed by the risk.
New uses of %n don't seem to be entering the C ecosystem, as static
tools flag them. And everyone points fingers at those people....
The list of programs (and libraries) which use %n is therefore finite
and shrinking. Most of the %n use comes out of the GNU ecosystem.
jca@ has convinced gnulib to fix their code (so we need to wait for
software including gnulib to make new releases).
A few libraries have moved ahead of us and become more strict. Some n
longer permit %n (for instance, andriod bionic). Others log the occurance.
Some log and abort if the output location is W|X (MacOS).
Our base tree is clean. The ports tree contains a handful during
build time, and unknown count (more) during runtime.
We would like to abort programs on any occurance of %n. Or we could
be like MacOS, aborting for W|X pages (but would need a system call
which can check that condition, and that introduces addressspace
knowledge we don't want attackers to know, and may be a poor tradeoff).
For now, we can syslog, to increase awareness, and involve more people
in the greater community to remove %n uses.
[If %n is at the end, use the *printf return value. If it occurs in
the middle, split the printf calls into multiples]
Hopefully one day, we can just abort() when %n happens. Help us get
there?
ok jca, plus naddy for ports team
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
using mbrtowc(3). Thus, we now treat the format string as a bytestring,
not as a multibyte character string.
We think that ANSI C made a small error when adding wide characters:
The committees essentially replaced "characters" with "wide characters"
in the existing printf documentation, which was written before the
concept of processing was established. Doing processing on the format
string would break some 8-bit format strings in the wild, and that
isn't something these committees gave themselves license to do.
Based on the "10x printf speedup" commit from android found by tedu:
https://github.com/aosp-mirror/platform_bionic/commit/5305a4d4a723b06494b93f2df81733b83a0c46d3
Thanks to millert and schwarze for digging into the history and
testing *printf behavior on other platforms.
ok deraadt, millert
|
|
|
|
| |
OK schwarze@
|
|
|
|
| |
to determine the length instead of doing it manually. OK schwarze@
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
| |
ok millert@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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@
|
|
|
|
| |
ok and valuable input from millert@
|
|
|
|
| |
ok millert@
|
|
|
|
|
|
|
|
|
|
|
|
| |
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@
|
|
|
|
| |
ok martynas@, millert@, doug@
|
|
|
|
|
|
|
| |
don't use disable %n ourselves. But Google's Android libc is based
on our libc.... Giving them an easy knob to disable this dangerous
feature easily make their job easier without making our job any harder.
Request from Elliott @ google
|
| |
|
|
|
|
| |
ok deraadt@
|
|
|
|
| |
ok deraadt@ kettenis@ millert@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
printf() and avoid calling it unless needed (i.e., when we have a
floating point value to print). This isn't a big concern currently
due to our limited locale support and current localeconv()
implementation, but it's still technically a data race and
implementing POSIX 2008 per-thread locales is likely to make it worse.
nl_langinfo() isn't guaranteed by POSIX to be thread-safe either, but
at least our current implementation is thread-safe and it's a simpler
interface to keep that way. Printing floating point values isn't
async-signal-safe anyway due to gdtoa()'s use of malloc(), so that's
not an issue.
ok deraadt, stsp, millert
|
|
|
|
|
|
| |
the vfprintf(3) man page for ages. Based on code from NetBSD/FreeBSD.
Prevent ramdisk growth with a maze of #ifdefs.
ok robert, no objections deraadt, espie, millert
|
| |
|
|
|
|
| |
Noted by Claus Assmann
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
internally when and where required. Macros in <stdio.h> are updated
to automatically call the underlying functions when the process is
threaded to obtain the necessary locking. A private mutex is added
to protect __sglue, the internal list of FILE handles, and another
to protect the one-time initialization. Some routines in libc that
use getc() change to use getc_unlocked() as they're either protected
by their own lock or aren't thread-safe routines anyway.
committing on behalf of and okay guenther@ now that we have install
media space available.
|
| |
|
|
|
|
| |
media to fit
|
|
|
|
|
|
|
|
|
|
|
|
| |
internally when and where required. Macros in <stdio.h> are updated
to automatically call the underlying functions when the process is
threaded to obtain the necessary locking. A private mutex is added
to protect __sglue, the internal list of FILE handles, and another
to protect the one-time initialization. Some routines in libc that
use getc() change to use getc_unlocked() as they're either protected
by their own lock or aren't thread-safe routines anyway.
ok kurt@, earlier version tested by sthen@ and jj@
|
|
|
|
|
|
| |
ecvt, fcvt, gcvt, *printf, strtof, strtod, strtold act per ieee
1003.1. after these massive changes, remove unused files which
would not work now. reported by Maksymilian Arciemowicz; ok theo
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- provide proper dtoa locks
- use the real strtof implementation
- add strtold, __hdtoa, __hldtoa
- add %a/%A support
- don't lose precision in printf, don't round to double anymore
- implement extended-precision versions of libc functions: fpclassify,
isnan, isinf, signbit, isnormal, isfinite, now that the ieee.h is
fixed
- separate vax versions of strtof, and __hdtoa
- add complex math support. added functions: cacos, casin, catan,
ccos, csin, ctan, cacosh, casinh, catanh, ccosh, csinh, ctanh, cexp,
clog, cabs, cpow, csqrt, carg, cimag, conj, cproj, creal, cacosf,
casinf, catanf, ccosf, csinf, ctanf, cacoshf, casinhf, catanhf,
ccoshf, csinhf, ctanhf, cexpf, clogf, cabsf, cpowf, csqrtf, cargf,
cimagf, conjf, cprojf, crealf
- add fdim, fmax, fmin
- add log2. (adapted implementation e_log.c. could be more acruate
& faster, but it's good enough for now)
- remove wrappers & cruft in libm, supposed to work-around mistakes
in SVID, etc.; use ieee versions. fixes issues in python 2.6 for
djm@
- make _digittoint static
- proper definitions for i386, and amd64 in ieee.h
- sh, powerpc don't really have extended-precision
- add missing definitions for mips64 (quad), m{6,8}k (96-bit) float.h
for LDBL_*
- merge lead to frac for m{6,8}k, for gdtoa to work properly
- add FRAC*BITS & EXT_TO_ARRAY32 definitions in ieee.h, for hdtoa&ldtoa
to use
- add EXT_IMPLICIT_NBIT definition, which indicates implicit
normalization bit
- add regression tests for libc: fpclassify and printf
- arith.h & gd_qnan.h definitions
- update ieee.h: hppa doesn't have quad-precision, hppa64 does
- add missing prototypes to gdtoaimp
- on 64-bit platforms make sure gdtoa doesn't use a long when it
really wants an int
- etc., what i may have forgotten...
- bump libm major, due to removed&changed symbols
- no libc bump, since this is riding on djm's libc major crank from
a day ago
discussed with / requested by / testing theo, sthen@, djm@, jsg@,
merdely@, jsing@, tedu@, brad@, jakemsr@, and others.
looks good to millert@
parts of the diff ok kettenis@
this commit does not include:
- man page changes
|
| |
|
|
|
|
|
|
| |
- make inf INF nan NAN comply to standards (eEfFgG)
- extend man page bits
ok millert@. w/ a man page tweak and ok jmc@
|
| |
|
|
|
|
|
|
| |
- remove 'value < 0' cruft, dtoa already clears sign bit for us
discussed with, and tested by phessler@
ok millert@, who noticed to remove now-unused variable, and phessler@
|
| |
|
|
|
|
|
| |
Replace the non-portable hackery in __find_arguments() with a union.
From FreeBSD.
|
| |
|
|
|
|
| |
ok espie@
|
|
|
|
| |
ok millert tedu
|
|
|
|
|
|
|
|
|
|
|
| |
p - cp cannot be greater than prec).
Prevent an integer overflow when printing a string with length
greater than INT_MAX.
Initial diff from millert@.
OK millert@, beck@, and otto@.
|
|
|
|
| |
values for the field width. Adapted from a diff by Christian Biere.
|
|
|
|
| |
of 2 from 16 to pagesize(); ok otto
|
|
|
|
|
| |
codebase. tested mostly by ckuethe and myself. __dtoa() use now requires
a call to __freedtoa()
|
|
|
|
|
|
|
| |
callers do not yet check since printf() for example is not documented
to return an error.
some formatting cleanups.
mostly ok deraadt millert
|
|
|
|
| |
part from FreeBSD.
|
|
|
|
|
| |
Add new sys/_types.h header
Include machine/_types.h or sys/_types.h where applicable
|
| |
|
|
|
|
|
| |
sent out and approved about 6 months ago and has been rotting in
my tree ever since.
|
|
|
|
| |
ok deraadt espie kettenis
|
|
|
|
|
|
| |
Kill old files that are no longer compiled.
okay theo
|
|
|
|
|
| |
reviewed by millert, otto, kevlo, naddy, kettenis...
libc+libstdc++ bump
|
|
|
|
|
|
|
| |
Use stateful functions for mbtowc.
Use the same loop for scanning and for rescanning the format.
okay millert@
|