diff options
| author | U.Nakamura <usa@ruby-lang.org> | 2023-07-25 20:37:25 +0900 |
|---|---|---|
| committer | U.Nakamura <usa@ruby-lang.org> | 2023-07-25 20:37:40 +0900 |
| commit | aac3232ab09f649c5de86a1ef7b942de3cc218ce (patch) | |
| tree | 10a24a9877e6da6b8d0843552f62a3ed6443bd32 | |
| parent | 3799270ec27b1267cd9923dae00bcb3955f7e061 (diff) | |
merge revision(s) fac814c2dc31afef272b45392a7389ef0bfa3a4f: [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
| -rw-r--r-- | regint.h | 9 | ||||
| -rw-r--r-- | version.h | 2 |
2 files changed, 9 insertions, 2 deletions
@@ -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) @@ -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 |
