Skip to content

Openvela fortify fix #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEFAULT_TASK_STACKSIZE=4096
CONFIG_ETC_ROMFS=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_FORTIFY_SOURCE=3
CONFIG_FS_HOSTFS=y
CONFIG_FS_PROCFS=y
CONFIG_FS_ROMFS=y
Expand Down
1 change: 1 addition & 0 deletions boards/xtensa/iss-hifi4/iss-hifi4/configs/nsh/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEFAULT_TASK_STACKSIZE=4096
CONFIG_ETC_ROMFS=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_FORTIFY_SOURCE=3
CONFIG_FS_HOSTFS=y
CONFIG_FS_PROCFS=y
CONFIG_FS_ROMFS=y
Expand Down
8 changes: 3 additions & 5 deletions include/nuttx/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@
# warning requires compiling with optimization (-O2 or higher)
# endif
# if CONFIG_FORTIFY_SOURCE == 3
# if __GNUC__ < 12 || (defined(__clang__) && __clang_major__ < 12)
# error compiler version less than 12 does not support dynamic object size
# endif

# define fortify_size(__o, type) __builtin_dynamic_object_size(__o, type)
# else
# define fortify_size(__o, type) __builtin_object_size(__o, type)
Expand All @@ -131,7 +127,9 @@
} \
while (0)

# define fortify_va_arg_pack __builtin_va_arg_pack
# if !defined(__clang__)
# define fortify_va_arg_pack __builtin_va_arg_pack
# endif
# define fortify_real(fn) __typeof__(fn) __real_##fn __asm__(#fn)
# define fortify_function(fn) fortify_real(fn); \
extern __inline__ no_builtin(#fn) \
Expand Down
2 changes: 2 additions & 0 deletions include/stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ fortify_function(vsprintf) int vsprintf(FAR char *dest,
return ret;
}

#ifdef fortify_va_arg_pack
fortify_function(snprintf) int snprintf(FAR char *buf, size_t size,
FAR const IPTR char *format, ...)
{
Expand All @@ -336,6 +337,7 @@ fortify_function(sprintf) int sprintf(FAR char *buf,
return ret;
}
#endif
#endif

#undef EXTERN
#if defined(__cplusplus)
Expand Down
Loading