dvb: Fix sockaddr_un usage

The sun_path field needs to be NULL-terminated

CID #206004
This commit is contained in:
Edward Hervey 2017-11-04 07:49:24 +01:00 committed by Edward Hervey
parent c4d5181b09
commit b9e8ffb4be

View file

@ -76,7 +76,12 @@ cam_sw_client_open (CamSwClient * client, const char *sock_path)
g_return_val_if_fail (client != NULL, FALSE);
g_return_val_if_fail (client->state == CAM_SW_CLIENT_STATE_CLOSED, FALSE);
g_return_val_if_fail (sock_path != NULL, FALSE);
g_return_val_if_fail (strlen (sock_path) >= sizeof (addr.sun_path), FALSE);
/* sun.path needs to end up NULL-terminated */
if (strlen (sock_path) >= (sizeof (addr.sun_path) - 1)) {
GST_ERROR ("sock_path is too long");
return FALSE;
}
addr.sun_family = AF_UNIX;
strncpy (addr.sun_path, sock_path, sizeof (addr.sun_path));