extern int __REDIRECT (__open_alias, (const char *__path, int __oflag, ...),
open64) __nonnull ((1));
#endif
+
+#ifdef __va_arg_pack_len
__errordecl (__open_too_many_args,
"open can be called either with 2 or 3 arguments, not more");
__errordecl (__open_missing_mode,
return __open_alias (__path, __oflag, __va_arg_pack ());
}
+#elif __fortify_use_clang
+__fortify_function_error_function __attribute_overloadable__ int
+open (const char *__path, int __oflag, mode_t __mode, ...)
+ __fortify_clang_unavailable ("open can be called either with 2 or 3 arguments, not more");
+
+__fortify_function __attribute_overloadable__ int
+open (__fortify_clang_overload_arg (const char *, ,__path), int __oflag)
+ __fortify_clang_prefer_this_overload
+ __fortify_clang_error (__OPEN_NEEDS_MODE (__oflag),
+ "open with O_CREAT or O_TMPFILE in second argument needs 3 arguments")
+{
+ return __open_2 (__path, __oflag);
+}
+
+__fortify_function __attribute_overloadable__ int
+open (__fortify_clang_overload_arg (const char *, ,__path), int __oflag,
+ mode_t __mode)
+{
+ return __open_alias (__path, __oflag, __mode);
+}
+#endif
#ifdef __USE_LARGEFILE64
extern int __open64_2 (const char *__path, int __oflag) __nonnull ((1));
extern int __REDIRECT (__open64_alias, (const char *__path, int __oflag,
...), open64) __nonnull ((1));
+# ifdef __va_arg_pack_len
__errordecl (__open64_too_many_args,
"open64 can be called either with 2 or 3 arguments, not more");
__errordecl (__open64_missing_mode,
return __open64_alias (__path, __oflag, __va_arg_pack ());
}
+# elif __fortify_use_clang
+__fortify_function_error_function __attribute_overloadable__ int
+open64 (const char *__path, int __oflag, mode_t __mode, ...)
+ __fortify_clang_unavailable ("open64 can be called either with 2 or 3 arguments, not more");
+
+__fortify_function __attribute_overloadable__ int
+open64 (__fortify_clang_overload_arg (const char *, ,__path), int __oflag)
+ __fortify_clang_prefer_this_overload
+ __fortify_clang_error (__OPEN_NEEDS_MODE (__oflag),
+ "open64 with O_CREAT or O_TMPFILE in second argument needs 3 arguments")
+{
+ return __open64_2 (__path, __oflag);
+}
+
+__fortify_function __attribute_overloadable__ int
+open64 (__fortify_clang_overload_arg (const char *, ,__path), int __oflag,
+ mode_t __mode)
+{
+ return __open64_alias (__path, __oflag, __mode);
+}
+# endif
#endif
int __oflag, ...), openat64)
__nonnull ((2));
# endif
+
+# ifdef __va_arg_pack_len
__errordecl (__openat_too_many_args,
"openat can be called either with 3 or 4 arguments, not more");
__errordecl (__openat_missing_mode,
return __openat_alias (__fd, __path, __oflag, __va_arg_pack ());
}
+# elif __fortify_use_clang
+__fortify_function_error_function __attribute_overloadable__ int
+openat (int __fd, const char *__path, int __oflag, mode_t __mode, ...)
+ __fortify_clang_unavailable ("openat can be called either with 3 or 4 arguments, not more");
+
+__fortify_function __attribute_overloadable__ int
+openat (int __fd, __fortify_clang_overload_arg (const char *, ,__path),
+ int __oflag)
+ __fortify_clang_prefer_this_overload
+ __fortify_clang_error (__OPEN_NEEDS_MODE (__oflag),
+ "openat with O_CREAT or O_TMPFILE in third argument needs 4 arguments")
+{
+ return __openat_2 (__fd, __path, __oflag);
+}
+
+__fortify_function __attribute_overloadable__ int
+openat (int __fd, __fortify_clang_overload_arg (const char *, ,__path),
+ int __oflag, mode_t __mode)
+{
+ return __openat_alias (__fd, __path, __oflag, __mode);
+}
+# endif
# ifdef __USE_LARGEFILE64
__errordecl (__openat64_missing_mode,
"openat64 with O_CREAT or O_TMPFILE in third argument needs 4 arguments");
+# ifdef __va_arg_pack_len
__fortify_function int
openat64 (int __fd, const char *__path, int __oflag, ...)
{
return __openat64_alias (__fd, __path, __oflag, __va_arg_pack ());
}
+# elif __fortify_use_clang
+__fortify_function_error_function __attribute_overloadable__ int
+openat64 (int __fd, const char *__path, int __oflag, mode_t __mode, ...)
+ __fortify_clang_unavailable ("openat64 can be called either with 3 or 4 arguments, not more");
+
+__fortify_function __attribute_overloadable__ int
+openat64 (int __fd, __fortify_clang_overload_arg (const char *, ,__path),
+ int __oflag)
+ __fortify_clang_prefer_this_overload
+ __fortify_clang_error (__OPEN_NEEDS_MODE (__oflag),
+ "openat64 with O_CREAT or O_TMPFILE in third argument needs 4 arguments")
+{
+ return __openat64_2 (__fd, __path, __oflag);
+}
+
+__fortify_function __attribute_overloadable__ int
+openat64 (int __fd, __fortify_clang_overload_arg (const char *, ,__path),
+ int __oflag, mode_t __mode)
+{
+ return __openat64_alias (__fd, __path, __oflag, __mode);
+}
+# endif
# endif
#endif
# define __fortify_clang_warning(__c, __msg) \
__attribute__ ((__diagnose_if__ ((__c), (__msg), "warning")))
-# define __fortify_clang_warning_only_if_bos0_lt(n, buf, complaint) \
+# define __fortify_clang_error(__c, __msg) \
+ __attribute__ ((__diagnose_if__ ((__c), (__msg), "error")))
+# define __fortify_clang_warning_only_if_bos0_lt(n, buf, complaint) \
__attribute__ ((__diagnose_if__ \
(__fortify_clang_bosn_args (__bos0, n, buf, 1, complaint))))
# define __fortify_clang_warning_only_if_bos0_lt2(n, buf, div, complaint) \
__attribute__ ((__diagnose_if__ \
(__fortify_clang_bosn_args (__bos, n, buf, div, complaint))))
+# define __fortify_clang_prefer_this_overload \
+ __attribute__ ((enable_if (1, "")))
+# define __fortify_clang_unavailable(__msg) \
+ __attribute__ ((unavailable(__msg)))
+
# if __USE_FORTIFY_LEVEL == 3
# define __fortify_clang_overload_arg(__type, __attr, __name) \
__type __attr const __fortify_clang_pass_dynamic_object_size __name