diff --git a/src/ieee1905/topologyd.c b/src/ieee1905/topologyd.c
index 9dc381050eaba4e30881130dd780eb928f458f72..c626e1e6bba6f20d26fbb2d53cc3efa1d7fc3b1f 100644
--- a/src/ieee1905/topologyd.c
+++ b/src/ieee1905/topologyd.c
@@ -1521,10 +1521,8 @@ void topologyd_dump_node(struct blob_buf *bb, struct node *p, int is_self)
 			size = sizeof(behind_mac_str);
 
 			hwaddr_ntoa(p->l2_nbr[j].behind_intf_addr[k], mac_str);
-			if (k != 0)
-				snprintf(behind_mac_str + len, size, "%s,", behind_mac_str);
 
-			snprintf(behind_mac_str + len,  size, "%s", mac_str);
+			snprintf(behind_mac_str + len,  size - len , "%s,", mac_str);
 		}
 		blobmsg_add_string(bb, "behind_mac_id", behind_mac_str);
 		blobmsg_close_table(bb, table);