Commit f807767f9e5a2b70a054db585739a29ee6161838
1 parent
17399111
Use strcpy_s under Windows
Showing
1 changed file
with
5 additions
and
0 deletions
src/modbus-rtu.c
| @@ -1093,7 +1093,12 @@ modbus_new_rtu(const char *device, int baud, char parity, int data_bit, int stop | @@ -1093,7 +1093,12 @@ modbus_new_rtu(const char *device, int baud, char parity, int data_bit, int stop | ||
| 1093 | errno = ENOMEM; | 1093 | errno = ENOMEM; |
| 1094 | return NULL; | 1094 | return NULL; |
| 1095 | } | 1095 | } |
| 1096 | + | ||
| 1097 | +#if defined(_WIN32) | ||
| 1098 | + strcpy_s(ctx_rtu->device, strlen(device) + 1, device); | ||
| 1099 | +#else | ||
| 1096 | strcpy(ctx_rtu->device, device); | 1100 | strcpy(ctx_rtu->device, device); |
| 1101 | +#endif | ||
| 1097 | 1102 | ||
| 1098 | ctx_rtu->baud = baud; | 1103 | ctx_rtu->baud = baud; |
| 1099 | if (parity == 'N' || parity == 'E' || parity == 'O') { | 1104 | if (parity == 'N' || parity == 'E' || parity == 'O') { |