summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/strfmon.c
Commit message (Collapse)AuthorAgeFilesLines
* Compute the correct size of the string to move forward.John Baldwin2020-09-021-1/+1
| | | | | | | | | | | | | | | | | | | | Previously this was counting the amount of spare room at the start of the buffer that the string needed to move forward and passing that as the number of bytes to copy to memmove rather than the length of the string to be copied. In the strfmon test in the test suite this caused the memmove to overflow the allocated buffer by one byte which CHERI caught. Reported by: CHERI Reviewed by: kevans Obtained from: CheriBSD MFC after: 1 week Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26280 Notes: svn path=/head/; revision=365276
* Allow multi-byte thousands separators in strfmon(3)Conrad Meyer2018-12-191-14/+23
| | | | | | | | | | PR: 234010 Reported by: Jon Tejnung <jon AT herrskogen.se> Reviewed by: yuripv Differential Revision: https://reviews.freebsd.org/D18605 Notes: svn path=/head/; revision=342260
* libc: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-251-0/+2
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using mis-identified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326193
* libc: spelling fixes.Pedro F. Giffuni2016-04-301-2/+2
| | | | | | | Mostly on comments. Notes: svn path=/head/; revision=298830
* strfmon: reduce unnecessary snprintf.Pedro F. Giffuni2014-07-121-5/+3
| | | | | | | | | | No need for the snprintf/asprintf dance; use fixed width formats. Obtained from: NetBSD (CVS rev. 1.8) MFC after: 1 week Notes: svn path=/head/; revision=268569
* Implement xlocale APIs from Darwin, mainly for use by libc++. This adds aDavid Chisnall2011-11-201-8/+35
| | | | | | | | | | | | | | | load of _l suffixed versions of various standard library functions that use the global locale, making them take an explicit locale parameter. Also adds support for per-thread locales. This work was funded by the FreeBSD Foundation. Please test any code you have that uses the C standard locale functions! Reviewed by: das (gdtoa changes) Approved by: dim (mentor) Notes: svn path=/head/; revision=227753
* Fix PRMartin Cracauer2010-02-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/143350 Empty string test gone wrong. Testing this requires that you have a locale that has the sign string unset but has int_n_sign_posn set (the default locale falls through to use "()" around negative numbers which is probably another bug). I created that setup by hand and indeed without this fix negative numbers are put out as positive numbers (doesn't fall through to use "-" as default indicator). Unfixed example in nl_NL.ISO8859-1 with lc->negative_sign set to empty string: strfmon(buf, sizeof(buf), "%-8i", -42.0); ==> example2: 'EUR 42,00' 'Eu 42,00' Fixed: example2: 'EUR 42,00-' 'Eu 42,00-' This file and suggested fix are identical in at least freebsd-8. Backport might be appropriate but some expert on locales should probably have a look at us defaulting to negative numbers in parenthesis when LC_* is default. That doesn't look right and is not what other OSes are doing. PR: 143350 Submitted by: Corinna Vinschen Reviewed by: bug reporter submitted, tested by me Notes: svn path=/head/; revision=203734
* Stricter check for integer overflow.Ruslan Ermilov2008-04-241-0/+2
| | | | Notes: svn path=/head/; revision=178457
* Don't forget to free() currency_symbol and asciivalue when multipleRuslan Ermilov2008-04-191-0/+4
| | | | | | | | | | | conversion specifiers for them are present. Submitted by: Maxim Dounin <mdounin@mdounin.ru> Obtained from: NetBSD (partially) MFC after: 3 days Notes: svn path=/head/; revision=178313
* Better strfmon(3) conversion specifiers sanity checking.Ruslan Ermilov2008-04-191-1/+8
| | | | | | | | | | | | | There were no checks for left and right precisions at all, and a check for field width had integer overflow bug. Reported by: Maksymilian Arciemowicz Security: http://securityreason.com/achievement_securityalert/53 Submitted by: Maxim Dounin <mdounin@mdounin.ru> MFC after: 3 days Notes: svn path=/head/; revision=178312
* Use calloc() instaed of zeroing memory ourselves.Xin LI2008-04-131-2/+1
| | | | Notes: svn path=/head/; revision=178175
* Include a couple of headers to ensure consistency between the prototype andStefan Farfeleder2005-09-121-0/+1
| | | | | | | the function definition. Notes: svn path=/head/; revision=150065
* According to C99 decimal_point can't be emptyAndrey A. Chernov2003-03-201-4/+1
| | | | Notes: svn path=/head/; revision=112427
* Remove unused variable: ntmp.Tim J. Robbins2003-01-031-1/+0
| | | | Notes: svn path=/head/; revision=108624
* Fix a typo causing incorrect formatting for negative values in some localesTim J. Robbins2002-10-121-3/+5
| | | | | | | | | (at least the French ones), a memory leak upon successful termination, a pointer arithmetic error causing heap corruption, and an off-by-one bug causing incorrect amounts of padding at the right of the value. Notes: svn path=/head/; revision=104963
* Save errno around calls to free(); at least some code paths clobber itTim J. Robbins2002-10-111-0/+3
| | | | | | | and we are not interested in any errors it may report. Notes: svn path=/head/; revision=104946
* Use the new struct lconv members to determine how to format internationalTim J. Robbins2002-10-111-1/+12
| | | | | | | monetary values. Notes: svn path=/head/; revision=104944
* Non-negative amounts should not have an extra space in front of themTim J. Robbins2002-10-111-6/+2
| | | | | | | when the `(' flag is used. Notes: svn path=/head/; revision=104943
* "Left precision" and "right precision" are not flags, but separate partsTim J. Robbins2002-10-111-13/+15
| | | | | | | of the format string that appear after the field width. Notes: svn path=/head/; revision=104942
* Add restrict type-qualifier.Mike Barcroft2002-09-201-1/+2
| | | | Notes: svn path=/head/; revision=103668
* Assume __STDC__, remove non-__STDC__ code.Alfred Perlstein2002-05-281-17/+0
| | | | | | | Submitted by: keramida Notes: svn path=/head/; revision=97407
* Fix the style of the SCM ID's.David E. O'Brien2002-03-221-3/+2
| | | | | | | I believe have made all of libc .c's as consistent as possible. Notes: svn path=/head/; revision=92986
* Add my e-mail to copyrightsAlexey Zelkin2001-12-111-1/+1
| | | | Notes: svn path=/head/; revision=87659
* style(9)Mike Barcroft2001-09-171-62/+56
| | | | | | | Silence from: phantom Notes: svn path=/head/; revision=83559
* correctly wrap macros with { }Alexey Zelkin2001-09-061-2/+3
| | | | Notes: svn path=/head/; revision=83139
* Add strfmon(3) implementation. It still contains few XXX's because I lostAlexey Zelkin2001-09-051-0/+615
my last version of this work due to HDD crash, but this version cleanly passed all POSIX and SuSv2 tests. I am working on testing scripts which should test this implementation against all locales and surely more fixes will come soon. Reviewed by: ache, silence at -audit & -developers Notes: svn path=/head/; revision=83104