diff options
author | Samuel Holland <samuel@sholland.org> | 2018-01-14 22:39:41 -0600 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2018-01-15 00:02:54 -0600 |
commit | 101dbb13a1d0270b931291607962e6780ec856a5 (patch) | |
tree | c6aad3e51cdac4a44ef189eac9e38c3417ca5e6c /libgcompat/wchar.c | |
parent | c735fc99ec9e96520da0ea938890eed8fe64b50e (diff) | |
download | gcompat-101dbb13a1d0270b931291607962e6780ec856a5.tar.gz gcompat-101dbb13a1d0270b931291607962e6780ec856a5.tar.bz2 gcompat-101dbb13a1d0270b931291607962e6780ec856a5.tar.xz gcompat-101dbb13a1d0270b931291607962e6780ec856a5.zip |
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 <samuel@sholland.org>
Diffstat (limited to 'libgcompat/wchar.c')
-rw-r--r-- | libgcompat/wchar.c | 40 |
1 files changed, 40 insertions, 0 deletions
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.h> /* assert */ +#include <stdarg.h> /* va_list, va_start, va_end */ +#include <stddef.h> /* size_t */ +#include <wchar.h> /* 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); +} |