From 35e86a0cefccd1689c7cac1f8ed52674565292fe Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 11 Dec 2017 18:41:14 +0100 Subject: [PATCH] device: ensure simple action sdata is a NUL-terminated bytestring (cherry picked from commit 9639a176ffc06397bb74e6fd519ab292dea295f2) --- src/devices/nm-device.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index b8b4823f9f..afc81dcde7 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -5278,9 +5278,14 @@ tc_commit (NMDevice *self) if (action) { tfilter->action.kind = nm_tc_action_get_kind (action); if (strcmp (tfilter->action.kind, "simple") == 0) { - strncpy (tfilter->action.simple.sdata, - g_variant_get_bytestring (nm_tc_action_get_attribute (action, "sdata")), - sizeof (tfilter->action.simple.sdata)); + GVariant *sdata; + + sdata = nm_tc_action_get_attribute (action, "sdata"); + if (sdata && g_variant_is_of_type (sdata, G_VARIANT_TYPE_BYTESTRING)) { + g_strlcpy (tfilter->action.simple.sdata, + g_variant_get_bytestring (sdata), + sizeof (tfilter->action.simple.sdata)); + } } }