fcntl-linux-fortify.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Checking macros for fcntl functions. Linux version.
  2. Copyright (C) 2025-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #ifndef _FCNTL_H
  16. # error "Never include <bits/fcntl-linux-fortify.h> directly; use <fcntl.h> instead."
  17. #endif
  18. #ifdef __USE_GNU
  19. extern int __REDIRECT (__openat2_alias, (int __dfd, const char *__filename,
  20. const struct open_how *__how,
  21. size_t __usize), openat2)
  22. __nonnull ((2, 3));
  23. #if !__fortify_use_clang
  24. __errordecl (__openat2_invalid_size,
  25. "the specified size is larger than sizeof (struct open_how)");
  26. #endif
  27. __fortify_function int
  28. openat2 (int __dfd, const char *__filename, const struct open_how *__how,
  29. size_t __usize)
  30. __fortify_clang_warning (__builtin_constant_p (__usize)
  31. && __usize > sizeof (struct open_how),
  32. "the specified size is larger than sizeof (struct open_how)")
  33. {
  34. #if !__fortify_use_clang
  35. if (__builtin_constant_p (__usize) && __usize > sizeof (struct open_how))
  36. __openat2_invalid_size ();
  37. #endif
  38. return __openat2_alias (__dfd, __filename, __how, __usize);
  39. }
  40. #endif /* use GNU */