Assure NULL terminated strings in flexradio file.

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
Nate Bargmann 2012-01-07 21:48:05 -06:00
rodzic c941966b4a
commit ccbfdc42e1
1 zmienionych plików z 2 dodań i 2 usunięć

Wyświetl plik

@ -383,7 +383,7 @@ int dttsp_ipc_init(RIG *rig)
if (!cmdpath)
cmdpath = DEFAULT_DTTSP_CMD_PATH;
strncpy(rig->state.rigport.pathname, cmdpath, FILPATHLEN);
strncpy(rig->state.rigport.pathname, cmdpath, FILPATHLEN - 1);
return RIG_OK;
}
@ -423,7 +423,7 @@ int dttsp_ipc_open(RIG *rig)
p = getenv ( "SDR_METERPATH" );
if (!p) {
meterpath = priv->meter_port.pathname;
strncpy(meterpath, rig->state.rigport.pathname, FILPATHLEN);
strncpy(meterpath, rig->state.rigport.pathname, FILPATHLEN - 1);
p = strrchr(meterpath, '/');
strcpy(p+1, "SDRmeter");
p = meterpath;