diff --git a/src/rig.c b/src/rig.c index 651ef516a..65d6427a1 100644 --- a/src/rig.c +++ b/src/rig.c @@ -292,7 +292,7 @@ RIG * HAMLIB_API rig_init(rig_model_t rig_model) switch (caps->port_type) { case RIG_PORT_SERIAL: - strncpy(rs->rigport.pathname, DEFAULT_SERIAL_PORT, FILPATHLEN); + strncpy(rs->rigport.pathname, DEFAULT_SERIAL_PORT, FILPATHLEN - 1); rs->rigport.parm.serial.rate = caps->serial_rate_max; /* fastest ! */ rs->rigport.parm.serial.data_bits = caps->serial_data_bits; rs->rigport.parm.serial.stop_bits = caps->serial_stop_bits; @@ -301,16 +301,16 @@ RIG * HAMLIB_API rig_init(rig_model_t rig_model) break; case RIG_PORT_PARALLEL: - strncpy(rs->rigport.pathname, DEFAULT_PARALLEL_PORT, FILPATHLEN); + strncpy(rs->rigport.pathname, DEFAULT_PARALLEL_PORT, FILPATHLEN - 1); break; case RIG_PORT_NETWORK: case RIG_PORT_UDP_NETWORK: - strncpy(rs->rigport.pathname, "127.0.0.1:4532", FILPATHLEN); + strncpy(rs->rigport.pathname, "127.0.0.1:4532", FILPATHLEN - 1); break; default: - strncpy(rs->rigport.pathname, "", FILPATHLEN); + strncpy(rs->rigport.pathname, "", FILPATHLEN - 1); } rs->rigport.write_delay = caps->write_delay; diff --git a/src/rotator.c b/src/rotator.c index de9bf9979..a74986b19 100644 --- a/src/rotator.c +++ b/src/rotator.c @@ -223,7 +223,7 @@ ROT * HAMLIB_API rot_init(rot_model_t rot_model) switch (caps->port_type) { case RIG_PORT_SERIAL: - strncpy(rs->rotport.pathname, DEFAULT_SERIAL_PORT, FILPATHLEN); + strncpy(rs->rotport.pathname, DEFAULT_SERIAL_PORT, FILPATHLEN - 1); rs->rotport.parm.serial.rate = caps->serial_rate_max; /* fastest ! */ rs->rotport.parm.serial.data_bits = caps->serial_data_bits; rs->rotport.parm.serial.stop_bits = caps->serial_stop_bits; @@ -232,16 +232,16 @@ ROT * HAMLIB_API rot_init(rot_model_t rot_model) break; case RIG_PORT_PARALLEL: - strncpy(rs->rotport.pathname, DEFAULT_PARALLEL_PORT, FILPATHLEN); + strncpy(rs->rotport.pathname, DEFAULT_PARALLEL_PORT, FILPATHLEN - 1); break; case RIG_PORT_NETWORK: case RIG_PORT_UDP_NETWORK: - strncpy(rs->rotport.pathname, "127.0.0.1:4533", FILPATHLEN); + strncpy(rs->rotport.pathname, "127.0.0.1:4533", FILPATHLEN - 1); break; default: - strncpy(rs->rotport.pathname, "", FILPATHLEN); + strncpy(rs->rotport.pathname, "", FILPATHLEN - 1); } rs->min_el = caps->min_el;