Commit 884bf46
fix redis: use FromString for double reply values
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.
---
Pull Request resolved: #1297
Co-authored-by: antoshkka <antoshkka@userver.tech>
commit_hash:e5b7997828ad3c0a5d02d03bf9a62d907405f3bc1 parent 5392e2a commit 884bf46
3 files changed
Lines changed: 47 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4339 | 4339 | | |
4340 | 4340 | | |
4341 | 4341 | | |
| 4342 | + | |
4342 | 4343 | | |
4343 | 4344 | | |
4344 | 4345 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
266 | | - | |
| 266 | + | |
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
0 commit comments