Commit 5a66262d2e0e8d372d32fcb1c801cd88204a6bfd
1 parent
9a1c297c
Fix #241006 reported by Jesus Hernandez Tapia
modbus_check_response() crashes on an invalid exception code
Showing
2 changed files
with
8 additions
and
2 deletions
NEWS
| 1 | +libmodbus 2.0.1 (2008-07-XX) | ||
| 2 | +============================ | ||
| 3 | +- Include libmodbus.spec in the tarball | ||
| 4 | +- Fix #241006 reported by Jesus Hernandez Tapia | ||
| 5 | + modbus_check_response() crashes on an invalid exception code | ||
| 6 | + | ||
| 1 | libmodbus 2.0.0 (2008-05-18) | 7 | libmodbus 2.0.0 (2008-05-18) |
| 2 | ============================ | 8 | ============================ |
| 3 | - Slave API | 9 | - Slave API |
modbus/modbus.c
| @@ -662,9 +662,9 @@ static int modbus_check_response(modbus_param_t *mb_param, | @@ -662,9 +662,9 @@ static int modbus_check_response(modbus_param_t *mb_param, | ||
| 662 | return -exception_code; | 662 | return -exception_code; |
| 663 | } else { | 663 | } else { |
| 664 | /* The chances are low to hit this | 664 | /* The chances are low to hit this |
| 665 | - case but can avoid a vicious | 665 | + case but it can avoid a vicious |
| 666 | segfault */ | 666 | segfault */ |
| 667 | - char s_error[64]; | 667 | + char *s_error = malloc(64 * sizeof(char)); |
| 668 | sprintf(s_error, | 668 | sprintf(s_error, |
| 669 | "Invalid exception code %d", | 669 | "Invalid exception code %d", |
| 670 | response[offset + 2]); | 670 | response[offset + 2]); |