summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorU.Nakamura <usa@ruby-lang.org>2023-07-25 20:37:25 +0900
committerU.Nakamura <usa@ruby-lang.org>2023-07-25 20:37:40 +0900
commitaac3232ab09f649c5de86a1ef7b942de3cc218ce (patch)
tree10a24a9877e6da6b8d0843552f62a3ed6443bd32
parent3799270ec27b1267cd9923dae00bcb3955f7e061 (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.h9
-rw-r--r--version.h2
2 files changed, 9 insertions, 2 deletions
diff --git a/regint.h b/regint.h
index b136d804dc..34cc7efe1c 100644
--- a/regint.h
+++ b/regint.h
@@ -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)
diff --git a/version.h b/version.h
index 9841804328..cdb24afd0f 100644
--- a/version.h
+++ b/version.h
@@ -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