Blame SOURCES/0003-fix-segfault-in-adding-interface.patch

e607a6
From 690663d07f29789c1ba2260e59c4f71b8721dea6 Mon Sep 17 00:00:00 2001
e607a6
From: Vitezslav Samel <vitezslav@samel.cz>
e607a6
Date: Thu, 17 Apr 2014 14:24:23 +0200
e607a6
Subject: [PATCH 001/111] bugfix: positionptr(): properly allocate newly
e607a6
 created interfaces
e607a6
e607a6
When creating new entry in interface list (for interface created when
e607a6
ifstats() already running) we must allocate/init the rate too.
e607a6
e607a6
Fix this bug by creating new function alloc_iflist_entry() and use it
e607a6
where appropriate.
e607a6
e607a6
Signed-off-by: Vitezslav Samel <vitezslav@samel.cz>
e607a6
Signed-off-by: Nikola Pajkovsky <n.pajkovsky@gmail.com>
e607a6
---
e607a6
 src/ifstats.c | 16 ++++++++++++----
e607a6
 1 file changed, 12 insertions(+), 4 deletions(-)
e607a6
e607a6
diff --git a/src/ifstats.c b/src/ifstats.c
e607a6
index 2eb51b6..2a5bba4 100644
e607a6
--- a/src/ifstats.c
e607a6
+++ b/src/ifstats.c
e607a6
@@ -126,6 +126,15 @@ static int ifinlist(struct iflist *list, char *ifname)
e607a6
 	return result;
e607a6
 }
e607a6
 
e607a6
+static struct iflist *alloc_iflist_entry(void)
e607a6
+{
e607a6
+	struct iflist *tmp = xmallocz(sizeof(struct iflist));
e607a6
+
e607a6
+	rate_alloc(&tmp->rate, 5);
e607a6
+
e607a6
+	return tmp;
e607a6
+}
e607a6
+
e607a6
 /*
e607a6
  * Initialize the list of interfaces.  This linked list is used in the
e607a6
  * selection boxes as well as in the general interface statistics screen.
e607a6
@@ -171,10 +180,9 @@ static void initiflist(struct iflist **list)
e607a6
 		 * At this point, the interface is now sure to be up and running.
e607a6
 		 */
e607a6
 
e607a6
-		struct iflist *itmp = xmallocz(sizeof(struct iflist));
e607a6
-		strcpy(itmp->ifname, ifname);
e607a6
+		struct iflist *itmp = alloc_iflist_entry();
e607a6
 		itmp->ifindex = ifindex;
e607a6
-		rate_alloc(&itmp->rate, 5);
e607a6
+		strcpy(itmp->ifname, ifname);
e607a6
 
e607a6
 		/* make the linked list sorted by ifindex */
e607a6
 		struct iflist *cur = *list, *last = NULL;
e607a6
@@ -211,7 +219,7 @@ static struct iflist *positionptr(struct iflist *iflist, const int ifindex)
e607a6
 	}
e607a6
 	/* no interface was found, try to create new one */
e607a6
 	if (ptmp == NULL) {
e607a6
-		struct iflist *itmp = xmallocz(sizeof(struct iflist));
e607a6
+		struct iflist *itmp = alloc_iflist_entry();
e607a6
 		itmp->ifindex = ifindex;
e607a6
 		itmp->index = last->index + 1;
e607a6
 		int r = dev_get_ifname(ifindex, itmp->ifname);
e607a6
-- 
e607a6
2.5.5
e607a6