Skip to content

fix redis: use FromString for double reply values#1297

Open
netliomax25-code wants to merge 1 commit into
userver-framework:developfrom
netliomax25-code:redis-reply-double-parse
Open

fix redis: use FromString for double reply values#1297
netliomax25-code wants to merge 1 commit into
userver-framework:developfrom
netliomax25-code:redis-reply-double-parse

Conversation

@netliomax25-code

Copy link
Copy Markdown
Contributor
  1. Parse(..., To<double>) converts floating-point reply values (ZSCORE, HINCRBYFLOAT, ZADD ... INCR) with std::stod, which respects the process LC_NUMERIC and keeps only the valid numeric prefix of the string.
  2. under a comma-decimal locale "3.14" parses as 3.0, and a reply like "3.14x" parses as 3.14 with the trailing bytes silently dropped, so a compromised or MITM'd server can return a corrupted value.

Switched to utils::FromString<double>, matching the geo parser at line 58 and the score parser at line 166 in this file: it is locale-independent and rejects trailing junk, while numbers, scientific notation, and inf/-inf still parse the same. Added a regression test for the trailing-junk case along with valid and infinite values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant