arm-trusted-firmware/lib/libc
Andre Przywara c1f5a0925d fix(libc): fix snprintf corner cases
The number formatting routine in snprintf was trying to be clever with
the buffer handling, but tripped over its own feet: snprintf() users
expect output to be emitted, even if not everything fits into the
buffer. The current code gives up completely when the buffer is too
small.

Fix those issues and simplify the code on the way, by consequently using
the CHECK_AND_PUT_CHAR() macro, which both checks for the buffer size
correctly, but also keeps track of the number of should-be-printed
characters for the return value.

Change-Id: Ifd2b03b9a73f9279abed53081a2d88720ecbdbc1
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2022-02-07 16:14:21 +00:00
..
aarch32 plat/arm: Introduce and use libc_asm.mk makefile 2020-09-02 16:21:34 +00:00
aarch64 plat/arm: Introduce and use libc_asm.mk makefile 2020-09-02 16:21:34 +00:00
abort.c Sanitise includes across codebase 2019-01-04 10:43:17 +00:00
assert.c Don't return error information from console_flush 2020-10-09 10:21:50 -05:00
exit.c libc: Fix some MISRA defects 2018-08-30 16:21:59 +01:00
libc.mk libc: Import strtoull from FreeBSD project 2021-02-03 10:36:33 -06:00
libc_asm.mk libc: Import strtoull from FreeBSD project 2021-02-03 10:36:33 -06:00
memchr.c libc: fix memchr implementation 2019-06-20 09:59:24 +01:00
memcmp.c Remove several warnings reported with W=1 2019-04-01 10:43:42 +01:00
memcpy.c Remove several warnings reported with W=1 2019-04-01 10:43:42 +01:00
memmove.c libc: Cleanup remaining files 2018-08-22 10:26:04 +01:00
memrchr.c libc: add memrchr 2019-12-11 08:51:26 +01:00
memset.c libc: memset: Fix MISRA issues 2021-02-24 09:33:59 +00:00
printf.c libc/printf: add support to print "%" character 2021-01-20 13:09:13 +08:00
putchar.c Sanitise includes across codebase 2019-01-04 10:43:17 +00:00
puts.c libc: Fix some MISRA defects 2018-08-30 16:21:59 +01:00
snprintf.c fix(libc): fix snprintf corner cases 2022-02-07 16:14:21 +00:00
strchr.c libc: Cleanup FreeBSD files 2018-08-22 10:26:05 +01:00
strcmp.c libc: Cleanup FreeBSD files 2018-08-22 10:26:05 +01:00
strlcat.c libc: Import strlcat from FreeBSD project 2020-09-09 13:48:04 -05:00
strlcpy.c libc: Adapt strlcpy to this codebase 2018-11-02 13:41:33 +00:00
strlen.c libc: Introduce cdefs.h, assert.h and strlen.c 2018-08-22 10:26:04 +01:00
strncmp.c libc: Cleanup FreeBSD files 2018-08-22 10:26:05 +01:00
strnlen.c libc: Cleanup FreeBSD files 2018-08-22 10:26:05 +01:00
strrchr.c libc: Integrate strrchr in libc 2018-10-23 18:27:45 +01:00
strtok.c libc: Import strtok_r from FreeBSD project 2020-09-18 11:58:41 -05:00
strtol.c libc: Import strtol from FreeBSD project 2021-02-03 10:36:33 -06:00
strtoll.c libc: Import strtoll from FreeBSD project 2021-02-03 10:36:33 -06:00
strtoul.c libc: Import strtoul from FreeBSD project 2021-02-03 10:36:33 -06:00
strtoull.c libc: Import strtoull from FreeBSD project 2021-02-03 10:36:33 -06:00