mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 00:31:13 +00:00
ptp: Ensure that not too much is read from or written to struct ifreq.ifr_name
This commit is contained in:
parent
0d96487879
commit
c8d777feaa
1 changed files with 5 additions and 5 deletions
|
@ -253,16 +253,16 @@ setup_sockets (void)
|
||||||
probed_ifaces = g_new0 (gchar *, ifc.ifc_len + 1);
|
probed_ifaces = g_new0 (gchar *, ifc.ifc_len + 1);
|
||||||
|
|
||||||
for (i = 0; i < ifc.ifc_len / sizeof (struct ifreq); i++) {
|
for (i = 0; i < ifc.ifc_len / sizeof (struct ifreq); i++) {
|
||||||
strcpy (ifr.ifr_name, ifc.ifc_req[i].ifr_name);
|
strncpy (ifr.ifr_name, ifc.ifc_req[i].ifr_name, IFNAMSIZ);
|
||||||
if (ioctl (g_socket_get_fd (socket_event), SIOCGIFFLAGS, &ifr) == 0) {
|
if (ioctl (g_socket_get_fd (socket_event), SIOCGIFFLAGS, &ifr) == 0) {
|
||||||
if ((ifr.ifr_flags & IFF_LOOPBACK))
|
if ((ifr.ifr_flags & IFF_LOOPBACK))
|
||||||
continue;
|
continue;
|
||||||
probed_ifaces[idx] = g_strdup (ifc.ifc_req[i].ifr_name);
|
probed_ifaces[idx] = g_strndup (ifc.ifc_req[i].ifr_name, IFNAMSIZ);
|
||||||
idx++;
|
idx++;
|
||||||
} else {
|
} else {
|
||||||
g_warning ("can't get flags of interface '%s'",
|
g_warning ("can't get flags of interface '%s'",
|
||||||
ifc.ifc_req[i].ifr_name);
|
ifc.ifc_req[i].ifr_name);
|
||||||
probed_ifaces[idx] = g_strdup (ifc.ifc_req[i].ifr_name);
|
probed_ifaces[idx] = g_strndup (ifc.ifc_req[i].ifr_name, IFNAMSIZ);
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
if (idx != 0)
|
if (idx != 0)
|
||||||
|
@ -305,7 +305,7 @@ setup_sockets (void)
|
||||||
gchar **ptr = ifaces;
|
gchar **ptr = ifaces;
|
||||||
|
|
||||||
while (*ptr) {
|
while (*ptr) {
|
||||||
strcpy (ifr.ifr_name, *ptr);
|
strncpy (ifr.ifr_name, *ptr, IFNAMSIZ);
|
||||||
if (ioctl (g_socket_get_fd (socket_event), SIOCGIFHWADDR, &ifr) == 0) {
|
if (ioctl (g_socket_get_fd (socket_event), SIOCGIFHWADDR, &ifr) == 0) {
|
||||||
clock_id_array[0] = ifr.ifr_hwaddr.sa_data[0];
|
clock_id_array[0] = ifr.ifr_hwaddr.sa_data[0];
|
||||||
clock_id_array[1] = ifr.ifr_hwaddr.sa_data[1];
|
clock_id_array[1] = ifr.ifr_hwaddr.sa_data[1];
|
||||||
|
@ -331,7 +331,7 @@ setup_sockets (void)
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
for (i = 0; i < ifc.ifc_len / sizeof (struct ifreq); i++) {
|
for (i = 0; i < ifc.ifc_len / sizeof (struct ifreq); i++) {
|
||||||
strcpy (ifr.ifr_name, ifc.ifc_req[i].ifr_name);
|
strncpy (ifr.ifr_name, ifc.ifc_req[i].ifr_name, IFNAMSIZ);
|
||||||
if (ioctl (g_socket_get_fd (socket_event), SIOCGIFFLAGS, &ifr) == 0) {
|
if (ioctl (g_socket_get_fd (socket_event), SIOCGIFFLAGS, &ifr) == 0) {
|
||||||
if ((ifr.ifr_flags & IFF_LOOPBACK))
|
if ((ifr.ifr_flags & IFF_LOOPBACK))
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in a new issue