gst: Use memcpy() instead of strncpy() where appropriate

strncpy() is assumed to be for strings so the compiler assumes that
it will need an extra byte for the string-terminaning NULL.

For cases where we know it's actually "binary" data, just copy it
with memcpy.

https://bugzilla.gnome.org/show_bug.cgi?id=795756
This commit is contained in:
Edward Hervey 2018-05-04 09:29:22 +02:00 committed by Edward Hervey
parent 69ddcc175f
commit 80dfb7bb3f
2 changed files with 2 additions and 2 deletions

View file

@ -336,7 +336,7 @@ gst_registry_binary_initialize_magic (GstBinaryRegistryMagic * m)
{
memset (m, 0, sizeof (GstBinaryRegistryMagic));
if (!strncpy (m->magic, GST_MAGIC_BINARY_REGISTRY_STR,
if (!memcpy (m->magic, GST_MAGIC_BINARY_REGISTRY_STR,
GST_MAGIC_BINARY_REGISTRY_LEN)
|| !strncpy (m->version, GST_MAGIC_BINARY_VERSION_STR,
GST_MAGIC_BINARY_VERSION_LEN)) {

View file

@ -317,7 +317,7 @@ setup_sockets (void)
gchar **ptr = ifaces;
while (*ptr) {
strncpy (ifr.ifr_name, *ptr, IFNAMSIZ);
memcpy (ifr.ifr_name, *ptr, IFNAMSIZ);
if (ioctl (g_socket_get_fd (socket_event), SIOCGIFHWADDR, &ifr) == 0) {
clock_id_array[0] = ifr.ifr_hwaddr.sa_data[0];
clock_id_array[1] = ifr.ifr_hwaddr.sa_data[1];