kopia lustrzana https://github.com/Hamlib/Hamlib
Assure NULL terminated strings in src files.
Various strncpy operations could result in a port pathname that is not a NULL terminated string as the allowed string length is the same size as the buffer per the strncpy manual page. This is corrected by assuring that the allowed length is FILPATHLEN - 1.Hamlib-1.2.15
rodzic
1229a0a42a
commit
b31cc6ecd9
|
@ -292,7 +292,7 @@ RIG * HAMLIB_API rig_init(rig_model_t rig_model)
|
||||||
|
|
||||||
switch (caps->port_type) {
|
switch (caps->port_type) {
|
||||||
case RIG_PORT_SERIAL:
|
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.rate = caps->serial_rate_max; /* fastest ! */
|
||||||
rs->rigport.parm.serial.data_bits = caps->serial_data_bits;
|
rs->rigport.parm.serial.data_bits = caps->serial_data_bits;
|
||||||
rs->rigport.parm.serial.stop_bits = caps->serial_stop_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;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_PARALLEL:
|
case RIG_PORT_PARALLEL:
|
||||||
strncpy(rs->rigport.pathname, DEFAULT_PARALLEL_PORT, FILPATHLEN);
|
strncpy(rs->rigport.pathname, DEFAULT_PARALLEL_PORT, FILPATHLEN - 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_NETWORK:
|
case RIG_PORT_NETWORK:
|
||||||
case RIG_PORT_UDP_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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
strncpy(rs->rigport.pathname, "", FILPATHLEN);
|
strncpy(rs->rigport.pathname, "", FILPATHLEN - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rs->rigport.write_delay = caps->write_delay;
|
rs->rigport.write_delay = caps->write_delay;
|
||||||
|
|
|
@ -223,7 +223,7 @@ ROT * HAMLIB_API rot_init(rot_model_t rot_model)
|
||||||
|
|
||||||
switch (caps->port_type) {
|
switch (caps->port_type) {
|
||||||
case RIG_PORT_SERIAL:
|
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.rate = caps->serial_rate_max; /* fastest ! */
|
||||||
rs->rotport.parm.serial.data_bits = caps->serial_data_bits;
|
rs->rotport.parm.serial.data_bits = caps->serial_data_bits;
|
||||||
rs->rotport.parm.serial.stop_bits = caps->serial_stop_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;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_PARALLEL:
|
case RIG_PORT_PARALLEL:
|
||||||
strncpy(rs->rotport.pathname, DEFAULT_PARALLEL_PORT, FILPATHLEN);
|
strncpy(rs->rotport.pathname, DEFAULT_PARALLEL_PORT, FILPATHLEN - 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_PORT_NETWORK:
|
case RIG_PORT_NETWORK:
|
||||||
case RIG_PORT_UDP_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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
strncpy(rs->rotport.pathname, "", FILPATHLEN);
|
strncpy(rs->rotport.pathname, "", FILPATHLEN - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rs->min_el = caps->min_el;
|
rs->min_el = caps->min_el;
|
||||||
|
|
Ładowanie…
Reference in New Issue