merge revision(s) fac814c2dc: [Backport #19602]

Fix `PLATFORM_GET_INC`

	On platforms where unaligned word access is not allowed, and if
	`sizeof(val)` and `sizeof(type)` differ:

	- `val` > `type`, `val` will be a garbage.
	- `val` < `type`, outside `val` will be clobbered.
	---
	 regexec.c | 2 +-
	 regint.h  | 9 ++++++++-
	 2 files changed, 9 insertions(+), 2 deletions(-)

note: ruby_3_1 is patched regint.h only
This commit is contained in:
U.Nakamura 2023-07-25 20:37:25 +09:00
parent 3799270ec2
commit aac3232ab0
2 changed files with 9 additions and 2 deletions

View file

@ -303,9 +303,13 @@ RUBY_SYMBOL_EXPORT_BEGIN
#define ONIG_LAST_CODE_POINT (~((OnigCodePoint )0))
#define PLATFORM_GET_INC_ARGUMENTS_ASSERT(val, type) \
((void)sizeof(char[2 * (sizeof(val) == sizeof(type)) - 1]))
#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
# define PLATFORM_GET_INC(val,p,type) do{\
PLATFORM_GET_INC_ARGUMENTS_ASSERT(val, type);\
val = *(type* )p;\
(p) += sizeof(type);\
} while(0)
@ -313,7 +317,10 @@ RUBY_SYMBOL_EXPORT_BEGIN
#else
# define PLATFORM_GET_INC(val,p,type) do{\
xmemcpy(&val, (p), sizeof(type));\
PLATFORM_GET_INC_ARGUMENTS_ASSERT(val, type);\
type platform_get_value;\
xmemcpy(&platform_get_value, (p), sizeof(type));\
val = platform_get_value;\
(p) += sizeof(type);\
} while(0)

View file

@ -11,7 +11,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 4
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
#define RUBY_PATCHLEVEL 235
#define RUBY_PATCHLEVEL 236
#define RUBY_RELEASE_YEAR 2023
#define RUBY_RELEASE_MONTH 7