80 lines
2.2 KiB
Diff
80 lines
2.2 KiB
Diff
From d1267768e9f57ebcf86ff7f011aca7fb08e733eb Mon Sep 17 00:00:00 2001
|
|
From: Aaron Patterson <aaron@rubyonrails.org>
|
|
Date: Fri, 11 Feb 2022 11:23:01 -0800
|
|
Subject: [PATCH] Fix reloader to work with new Executor signature
|
|
|
|
This is a follow up to [CVE-2022-23633].
|
|
---
|
|
lib/active_support/reloader.rb | 2 +-
|
|
lib/active_support/execution_wrapper.rb | 29 ++++++++++---------
|
|
2 file changed, 11 insertion(+), 10 deletion(-)
|
|
|
|
diff --git a/lib/active_support/reloader.rb b/lib/active_support/reloader.rb
|
|
index 2f81cd4..e751866 100644
|
|
--- a/lib/active_support/reloader.rb
|
|
+++ b/lib/active_support/reloader.rb
|
|
@@ -58,7 +58,7 @@ module ActiveSupport
|
|
prepare!
|
|
end
|
|
|
|
- def self.run! # :nodoc:
|
|
+ def self.run!(reset: false) # :nodoc:
|
|
if check!
|
|
super
|
|
else
|
|
|
|
diff --git a/lib/active_support/execution_wrapper.rb b/lib/active_support/execution_wrapper.rb
|
|
index ca810db584..07c4f435db 100644
|
|
--- a/lib/active_support/execution_wrapper.rb
|
|
+++ b/lib/active_support/execution_wrapper.rb
|
|
@@ -63,18 +63,21 @@ def self.register_hook(hook, outer: false)
|
|
# after the work has been performed.
|
|
#
|
|
# Where possible, prefer +wrap+.
|
|
- def self.run!
|
|
- if active?
|
|
- Null
|
|
+ def self.run!(reset: false)
|
|
+ if reset
|
|
+ lost_instance = active.delete(Thread.current)
|
|
+ lost_instance&.complete!
|
|
else
|
|
- new.tap do |instance|
|
|
- success = nil
|
|
- begin
|
|
- instance.run!
|
|
- success = true
|
|
- ensure
|
|
- instance.complete! unless success
|
|
- end
|
|
+ return Null if active?
|
|
+ end
|
|
+
|
|
+ new.tap do |instance|
|
|
+ success = nil
|
|
+ begin
|
|
+ instance.run!
|
|
+ success = true
|
|
+ ensure
|
|
+ instance.complete! unless success
|
|
end
|
|
end
|
|
end
|
|
@@ -103,11 +106,11 @@ def self.inherited(other) # :nodoc:
|
|
self.active = Concurrent::Hash.new
|
|
|
|
def self.active? # :nodoc:
|
|
- @active[Thread.current]
|
|
+ @active.key?(Thread.current)
|
|
end
|
|
|
|
def run! # :nodoc:
|
|
- self.class.active[Thread.current] = true
|
|
+ self.class.active[Thread.current] = self
|
|
run_callbacks(:run)
|
|
end
|
|
|
|
--
|
|
2.43.0
|
|
|