Skip to content

Commit

Permalink
Make cache id generation less predictable. Fixes #2326
Browse files Browse the repository at this point in the history
  • Loading branch information
mshibuya committed May 16, 2019
1 parent eb9c52e commit 818ad98
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/carrierwave/uploader/cache.rb
@@ -1,3 +1,5 @@
require 'securerandom'

module CarrierWave

class FormNotMultipart < UploadError
Expand All @@ -24,8 +26,8 @@ def self.increment
def self.generate_cache_id
[Time.now.utc.to_i,
Process.pid,
'%04d' % (CarrierWave::CacheCounter.increment % 1000),
'%04d' % rand(9999)
'%04d' % (CarrierWave::CacheCounter.increment % 10000),
'%04d' % SecureRandom.random_number(10000)
].map(&:to_s).join('-')
end

Expand Down

0 comments on commit 818ad98

Please sign in to comment.