Commit 7bb7b7f
authored
Out of Bounds read in valkey-benchmark (#4142)
Running:
```sh
./valkey-benchmark -t get 10000
```
causes `valkey-benchmark` to segfault.
After option parsing, the remaining argument (`10000`) is interpreted as
a repeat count for an arbitrary command sequence. Since no command
follows the repeat count, `start` becomes equal to `argc`.
When `start` becomes equal to `argc`, the parser evaluates
`sds_args[i][0]` before checking that `i` is still within bounds,
resulting in an out-of-bounds read and undefined behaviour.
This change guards the repeat-count parsing by checking `i < argc`
before accessing `sds_args[i]`.
Note: This avoids reading out of bounds but still does not handle what
happens after that.
Signed-off-by: lightsigma96 <8f34yashjadhav@gmail.com>1 parent 168c22a commit 7bb7b7f
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2513 | 2513 | | |
2514 | 2514 | | |
2515 | 2515 | | |
2516 | | - | |
| 2516 | + | |
2517 | 2517 | | |
2518 | 2518 | | |
2519 | 2519 | | |
| |||
0 commit comments