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

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