aboutsummaryrefslogtreecommitdiffstats
path: root/libc/bionic/__vsnprintf_chk.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libc/bionic/__vsnprintf_chk.cpp')
-rw-r--r--libc/bionic/__vsnprintf_chk.cpp41
1 files changed, 13 insertions, 28 deletions
diff --git a/libc/bionic/__vsnprintf_chk.cpp b/libc/bionic/__vsnprintf_chk.cpp
index a03d12fb6..ecf58168b 100644
--- a/libc/bionic/__vsnprintf_chk.cpp
+++ b/libc/bionic/__vsnprintf_chk.cpp
@@ -42,19 +42,13 @@
* This vsnprintf check is called if _FORTIFY_SOURCE is defined and
* greater than 0.
*/
-extern "C" int __vsnprintf_chk(
- char *dest,
- size_t supplied_size,
- int /*flags*/,
- size_t dest_len_from_compiler,
- const char *format,
- va_list va)
-{
- if (__predict_false(supplied_size > dest_len_from_compiler)) {
- __fortify_chk_fail("vsnprintf prevented write past end of buffer", 0);
- }
+extern "C" int __vsnprintf_chk(char* dest, size_t supplied_size, int /*flags*/,
+ size_t dest_len_from_compiler, const char* format, va_list va) {
+ if (__predict_false(supplied_size > dest_len_from_compiler)) {
+ __fortify_chk_fail("vsnprintf: prevented write past end of buffer", 0);
+ }
- return vsnprintf(dest, supplied_size, format, va);
+ return vsnprintf(dest, supplied_size, format, va);
}
/*
@@ -68,20 +62,11 @@ extern "C" int __vsnprintf_chk(
* This snprintf check is called if _FORTIFY_SOURCE is defined and
* greater than 0.
*/
-extern "C" int __snprintf_chk(
- char *dest,
- size_t supplied_size,
- int flags,
- size_t dest_len_from_compiler,
- const char *format, ...)
-{
- va_list va;
- int retval;
-
- va_start(va, format);
- retval = __vsnprintf_chk(dest, supplied_size, flags,
- dest_len_from_compiler, format, va);
- va_end(va);
-
- return retval;
+extern "C" int __snprintf_chk(char* dest, size_t supplied_size, int flags,
+ size_t dest_len_from_compiler, const char* format, ...) {
+ va_list va;
+ va_start(va, format);
+ int result = __vsnprintf_chk(dest, supplied_size, flags, dest_len_from_compiler, format, va);
+ va_end(va);
+ return result;
}