Assure NULL terminated strings in tuner 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
Nate Bargmann 2012-01-07 21:52:48 -06:00
rodzic ccbfdc42e1
commit 0c525a64e2
2 zmienionych plików z 2 dodań i 2 usunięć

Wyświetl plik

@ -157,7 +157,7 @@ const struct rig_caps v4l_caps = {
int v4l_init(RIG *rig)
{
rig->state.rigport.type.rig = RIG_PORT_DEVICE;
strncpy(rig->state.rigport.pathname, DEFAULT_V4L_PATH, FILPATHLEN);
strncpy(rig->state.rigport.pathname, DEFAULT_V4L_PATH, FILPATHLEN - 1);
return RIG_OK;
}

Wyświetl plik

@ -157,7 +157,7 @@ const struct rig_caps v4l2_caps = {
int v4l2_init(RIG *rig)
{
rig->state.rigport.type.rig = RIG_PORT_DEVICE;
strncpy(rig->state.rigport.pathname, DEFAULT_V4L2_PATH, FILPATHLEN);
strncpy(rig->state.rigport.pathname, DEFAULT_V4L2_PATH, FILPATHLEN - 1);
return RIG_OK;
}