Blob Blame History Raw
diff --git a/src/addressbooks.c b/src/addressbooks.c
index f0e5900..f7ac674 100644
--- a/src/addressbooks.c
+++ b/src/addressbooks.c
@@ -164,7 +164,8 @@ static gint mmgui_addressbooks_open_kde_socket(void)
 	memset(&address, 0, sizeof(struct sockaddr_un));
 
 	address.sun_family = AF_UNIX;
-	strncpy(address.sun_path, socketpath, sizeof(address.sun_path));
+	strncpy(address.sun_path, socketpath, sizeof(address.sun_path)-1);
+	address.sun_path[sizeof(address.sun_path)-1] = '\0';
 
 	g_free(socketpath);
 
diff --git a/src/mmguicore.c b/src/mmguicore.c
index 4fdc805..b460ff5 100644
--- a/src/mmguicore.c
+++ b/src/mmguicore.c
@@ -755,7 +755,8 @@ static GSList *mmguicore_modules_cache_form_list(mmguicore_t mmguicore)
 				continue;
 			}
 			/*Module filename*/
-			strncpy(modparams->filename, groups[i], sizeof(modparams->filename));
+			strncpy(modparams->filename, groups[i], sizeof(modparams->filename)-1);
+			modparams->filename[sizeof(modparams->filename)-1] = '\0';
 			/*Add to list*/
 			modules = g_slist_prepend(modules, modparams);
 		}
@@ -807,7 +808,8 @@ static GSList *mmguicore_modules_dir_form_list(mmguicore_t mmguicore, gboolean u
 						modparams = g_new0(struct _mmguimodule, 1);
 						if (module_init(modparams)) {
 							/*Add module filename*/
-							strncpy(modparams->filename, modname, sizeof(modparams->filename));
+							strncpy(modparams->filename, modname, sizeof(modparams->filename)-1);
+							modparams->filename[sizeof(modparams->filename)-1] = '\0';
 							/*Module successfully initialized and can be used*/
 							modules = g_slist_prepend(modules, modparams);
 							/*Add module to cache if needed*/
diff --git a/src/modules/connman112.c b/src/modules/connman112.c
index c91d848..72096b8 100644
--- a/src/modules/connman112.c
+++ b/src/modules/connman112.c
@@ -1219,7 +1219,7 @@ static gboolean mmgui_module_device_connection_initialize_contexts(mmguicore_t m
 																interface = g_variant_get_string(interfacev, &strlength);
 																if ((interface != NULL) && (interface[0] != '\0')) {
 																	memset(mmguicore->device->interface, 0, IFNAMSIZ);
-																	strncpy(mmguicore->device->interface, interface, IFNAMSIZ);
+																	strncpy(mmguicore->device->interface, interface, IFNAMSIZ-1);
 																	mmguicore->device->connected = TRUE;
 																}
 																/*Precache active context path*/
@@ -1282,7 +1282,7 @@ static gboolean mmgui_module_device_connection_initialize_contexts(mmguicore_t m
 								interface = g_variant_get_string(interfacev, &strlength);
 								if ((interface != NULL) && (interface[0] != '\0')) {
 									memset(mmguicore->device->interface, 0, IFNAMSIZ);
-									strncpy(mmguicore->device->interface, interface, IFNAMSIZ);
+									strncpy(mmguicore->device->interface, interface, IFNAMSIZ-1);
 									mmguicore->device->connected = TRUE;
 								}
 								/*Do not precache active context path - we have single connection*/
@@ -1447,7 +1447,7 @@ static void mmgui_module_device_context_property_changed_signal_handler(GDBusPro
 										interface = g_variant_get_string(interfacev, &strsize);
 										if ((interface != NULL) && (interface[0] != '\0')) {
 											memset(mmguicore->device->interface, 0, IFNAMSIZ);
-											strncpy(mmguicore->device->interface, interface, IFNAMSIZ);
+											strncpy(mmguicore->device->interface, interface, IFNAMSIZ-1);
 											mmguicore->device->connected = TRUE;
 										}
 										/*Precache active context path*/
@@ -1561,7 +1561,7 @@ static void mmgui_module_device_cdma_connection_manager_context_signal_handler(G
 										interface = g_variant_get_string(interfacev, &strsize);
 										if ((interface != NULL) && (interface[0] != '\0')) {
 											memset(mmguicore->device->interface, 0, IFNAMSIZ);
-											strncpy(mmguicore->device->interface, interface, IFNAMSIZ);
+											strncpy(mmguicore->device->interface, interface, IFNAMSIZ-1);
 											mmguicore->device->connected = TRUE;
 										}
 										/*Precache active context path*/
diff --git a/src/modules/nm09.c b/src/modules/nm09.c
index eeef280..2b3098b 100644
--- a/src/modules/nm09.c
+++ b/src/modules/nm09.c
@@ -177,7 +177,7 @@ static void mmgui_module_get_updated_interface_state(mmguicore_t mmguicore, gboo
 				devinterface = g_variant_get_string(devproperty, &strlength);
 				if ((devinterface != NULL) && (devinterface[0] != '\0')) {
 					memset(mmguicore->device->interface, 0, IFNAMSIZ);
-					strncpy(mmguicore->device->interface, devinterface, IFNAMSIZ);
+					strncpy(mmguicore->device->interface, devinterface, IFNAMSIZ-1);
 					mmguicore->device->connected = TRUE;
 				}
 				g_variant_unref(devproperty);
@@ -1183,7 +1183,7 @@ G_MODULE_EXPORT gboolean mmgui_module_device_connection_open(gpointer mmguicore,
 											nmdevinterface = g_variant_get_string(devproperties, &strlength);
 											if ((nmdevinterface != NULL) && (nmdevinterface[0] != '\0')) {
 												memset(mmguicorelc->device->interface, 0, IFNAMSIZ);
-												strncpy(mmguicorelc->device->interface, nmdevinterface, IFNAMSIZ);
+												strncpy(mmguicorelc->device->interface, nmdevinterface, IFNAMSIZ-1);
 												mmguicorelc->device->connected = TRUE;
 											} else {
 												memset(mmguicorelc->device->interface, 0, IFNAMSIZ);
diff --git a/src/netlink.c b/src/netlink.c
index 5e9dac4..1e98544 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -484,7 +484,8 @@ gboolean mmgui_netlink_read_interface_event(mmgui_netlink_t netlink, gchar *data
 			//Use tags to get additional data
 			while (RTA_OK(rta, msgheader->nlmsg_len)) {
 				if (rta->rta_type == IFLA_IFNAME) {
-					strncpy(event->ifname, (char *)RTA_DATA(rta), sizeof(event->ifname));
+					strncpy(event->ifname, (char *)RTA_DATA(rta), sizeof(event->ifname)-1);
+					event->ifname[sizeof(event->ifname)-1] = '\0';
 					g_debug("Tag: Device name: %s\n", (char *)RTA_DATA(rta));
 				} else if (rta->rta_type == IFLA_STATS) {
 					ifstats = (struct rtnl_link_stats *)RTA_DATA(rta);