Commit 6f915d4215c06be3c719761423d9b5e8aa3cb820
1 parent
890e689b
Fix my so stupid fix for VD-1301 vulnerability
I can't believe I committed that copy/paste mistake. Sorry Maor Vermucht and Or Peles, excepted naming your original patch was OK. Thank you Karl Palsson for your review.
Showing
1 changed file
with
1 additions
and
1 deletions
src/modbus.c
| ... | ... | @@ -874,7 +874,7 @@ int modbus_reply(modbus_t *ctx, const uint8_t *req, |
| 874 | 874 | int nb_bytes = req[offset + 5]; |
| 875 | 875 | int mapping_address = address - mb_mapping->start_registers; |
| 876 | 876 | |
| 877 | - if (nb < 1 || MODBUS_MAX_WRITE_REGISTERS < nb || nb_bytes * 8 < nb) { | |
| 877 | + if (nb < 1 || MODBUS_MAX_WRITE_REGISTERS < nb || nb_bytes != nb * 2) { | |
| 878 | 878 | rsp_length = response_exception( |
| 879 | 879 | ctx, &sft, MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE, rsp, TRUE, |
| 880 | 880 | "Illegal number of values %d in write_registers (max %d)\n", | ... | ... |