Просмотр исходного кода

Fix #241006 reported by Jesus Hernandez Tapia
modbus_check_response() crashes on an invalid exception code

Stéphane Raimbault 17 лет назад
Родитель
Сommit
5a66262d2e
2 измененных файлов с 8 добавлено и 2 удалено
  1. 6 0
      NEWS
  2. 2 2
      modbus/modbus.c

+ 6 - 0
NEWS

@@ -1,3 +1,9 @@
+libmodbus 2.0.1 (2008-07-XX)
+============================
+- Include libmodbus.spec in the tarball
+- Fix #241006 reported by Jesus Hernandez Tapia
+  modbus_check_response() crashes on an invalid exception code
+
 libmodbus 2.0.0 (2008-05-18)
 ============================
 - Slave API

+ 2 - 2
modbus/modbus.c

@@ -662,9 +662,9 @@ static int modbus_check_response(modbus_param_t *mb_param,
                                 return -exception_code;
                         } else {
                                 /* The chances are low to hit this
-                                   case but can avoid a vicious
+                                   case but it can avoid a vicious
                                    segfault */
-                                char s_error[64];
+                                char *s_error = malloc(64 * sizeof(char));
                                 sprintf(s_error,
                                         "Invalid exception code %d",
                                         response[offset + 2]);