Skip to content

Commit efccd23

Browse files
committed
fix: Zero/negative chunk size guard
Added `MINIMUM_CHUNK_SIZE = 1` constant and `[..., MINIMUM_CHUNK_SIZE].max` to prevent infinite loop
1 parent abbb998 commit efccd23

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/active_storage/service/db_service.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ class Service::DBService < Service
1818
end
1919
# :nocov:
2020

21+
MINIMUM_CHUNK_SIZE = 1
22+
2123
def initialize(public: false, **)
22-
@chunk_size = ENV.fetch("ASDB_CHUNK_SIZE") { 1.megabytes }.to_i
24+
@chunk_size = [ENV.fetch("ASDB_CHUNK_SIZE") { 1.megabytes }.to_i, MINIMUM_CHUNK_SIZE].max
2325
@public = public
2426
end
2527

0 commit comments

Comments
 (0)