serial_win.c: Copy the enough of the device name.

This commit is contained in:
Uwe Bonnes 2020-07-29 18:35:44 +02:00 committed by UweBonnes
parent 11217f8a45
commit 3eb51ce94f
1 changed files with 2 additions and 2 deletions

View File

@ -34,11 +34,11 @@ int serial_open(BMP_CL_OPTIONS_t *cl_opts, char * serial)
}
char device[256];
if (strstr(device, "\\\\.\\")) {
strncpy(device, cl_opts->opt_device, sizeof(cl_opts->opt_device) - 1);
strncpy(device, cl_opts->opt_device, sizeof(device) - 1);
} else {
strcpy(device, "\\\\.\\");
strncat(device, cl_opts->opt_device,
sizeof(cl_opts->opt_device) - strlen(cl_opts->opt_device) - 1);
sizeof(device) - strlen(device) - 1);
}
hComm = CreateFile(device, //port name
GENERIC_READ | GENERIC_WRITE, //Read/Write