From 101dbb13a1d0270b931291607962e6780ec856a5 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Sun, 14 Jan 2018 22:39:41 -0600 Subject: stdio: Clean up, add all of LSB stdio plus more * Add all (non-wchar) stdio functions from LSB, plus those found in use in other applications. Document those functions from LSB as such. * Use a consistent structure and paramater names for all functions. * flag == 0 means FORTIFY_SOURCE=1, so the implemented checks should be unconditional. * Add all possible checks without parsing the format string. * Move functions from wchar.h to their own appropriately-named file. Signed-off-by: Samuel Holland --- libgcompat/wchar.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 libgcompat/wchar.c (limited to 'libgcompat/wchar.c') diff --git a/libgcompat/wchar.c b/libgcompat/wchar.c new file mode 100644 index 0000000..1ddaa1f --- /dev/null +++ b/libgcompat/wchar.c @@ -0,0 +1,40 @@ +#include /* assert */ +#include /* va_list, va_start, va_end */ +#include /* size_t */ +#include /* wchar_t, *wprintf */ + +int __vswprintf_chk(wchar_t *s, size_t n, int flag, size_t slen, + const wchar_t *format, va_list ap); + +/** + * Convert formatted wide-character output, with stack checking + * + * LSB 5.0: LSB-Core-generic/baselib---swprintf-chk-1.html + */ +int __swprintf_chk(wchar_t *s, size_t n, int flag, size_t slen, + const wchar_t *format, ...) +{ + int ret; + va_list ap; + + va_start(ap, format); + ret = __vswprintf_chk(s, n, flag, slen, format, ap); + va_end(ap); + + return ret; +} + +/** + * Convert formatted wide-character output, with stack checking + * + * LSB 5.0: LSB-Core-generic/baselib---vswprintf-chk-1.html + */ +int __vswprintf_chk(wchar_t *s, size_t n, int flag, size_t slen, + const wchar_t *format, va_list ap) +{ + assert(s != NULL || n == 0); + assert(slen >= n); + assert(format != NULL); + + return vswprintf(s, n, format, ap); +} -- cgit v1.2.3-60-g2f50