Projects
Eulaceura:Mainline
rubygem-dalli
_service:obs_scm:CVE-2022-4064-1.patch
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:CVE-2022-4064-1.patch of Package rubygem-dalli
diff --git a/lib/dalli/protocol/meta.rb b/lib/dalli/protocol/meta.rb index 4d6c662d..b2e66c37 100644 --- a/lib/dalli/protocol/meta.rb +++ b/lib/dalli/protocol/meta.rb @@ -44,6 +44,7 @@ def gat(key, ttl, options = nil) end def touch(key, ttl) + ttl = TtlSanitizer.sanitize(ttl) encoded_key, base64 = KeyRegularizer.encode(key) req = RequestFormatter.meta_get(key: encoded_key, ttl: ttl, value: false, base64: base64) write(req) diff --git a/lib/dalli/protocol/meta/request_formatter.rb b/lib/dalli/protocol/meta/request_formatter.rb index b36a1219..7e485fea 100644 --- a/lib/dalli/protocol/meta/request_formatter.rb +++ b/lib/dalli/protocol/meta/request_formatter.rb @@ -31,7 +31,7 @@ def self.meta_set(key:, value:, bitflags: nil, cas: nil, ttl: nil, mode: :set, b cmd << ' c' unless %i[append prepend].include?(mode) cmd << ' b' if base64 cmd << " F#{bitflags}" if bitflags - cmd << " C#{cas}" if cas && !cas.zero? + cmd << cas_string(cas) cmd << " T#{ttl}" if ttl cmd << " M#{mode_to_token(mode)}" cmd << ' q' if quiet @@ -43,7 +43,7 @@ def self.meta_set(key:, value:, bitflags: nil, cas: nil, ttl: nil, mode: :set, b def self.meta_delete(key:, cas: nil, ttl: nil, base64: false, quiet: false) cmd = "md #{key}" cmd << ' b' if base64 - cmd << " C#{cas}" if cas && !cas.zero? + cmd << cas_string(cas) cmd << " T#{ttl}" if ttl cmd << ' q' if quiet cmd + TERMINATOR @@ -54,8 +54,9 @@ def self.meta_arithmetic(key:, delta:, initial:, incr: true, cas: nil, ttl: nil, cmd << ' b' if base64 cmd << " D#{delta}" if delta cmd << " J#{initial}" if initial - cmd << " C#{cas}" if cas && !cas.zero? - cmd << " N#{ttl}" if ttl + # Always set a TTL if an initial value is specified + cmd << " N#{ttl || 0}" if ttl || initial + cmd << cas_string(cas) cmd << ' q' if quiet cmd << " M#{incr ? 'I' : 'D'}" cmd + TERMINATOR @@ -75,7 +76,7 @@ def self.version def self.flush(delay: nil, quiet: false) cmd = +'flush_all' - cmd << " #{delay}" if delay + cmd << " #{parse_to_64_bit_int(delay, 0)}" if delay cmd << ' noreply' if quiet cmd + TERMINATOR end @@ -102,6 +103,18 @@ def self.mode_to_token(mode) end end # rubocop:enable Metrics/MethodLength + + def self.cas_string(cas) + cas = parse_to_64_bit_int(cas, nil) + cas.nil? || cas.zero? ? '' : " C#{cas}" + end + + def self.parse_to_64_bit_int(val, default) + val.nil? ? nil : Integer(val) + rescue ArgumentError + # Sanitize to default if it isn't parsable as an integer + default + end end end end
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2