Skip to contentSkip to conversation

nfsim at route del command.

PATCH In review Christian Hentschel 2 participants 3 messages Apr 29, 2005 – May 6, 2005 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfsim at route del command.

This patch fixes segfault at route del command.

route.c (working copy) renamed from route.c (revision 3887) +0 -0
@@ -17,6 +17,10 @@
 You should have received a copy of the GNU General Public License
 along with nfsim; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307

USA
+
+
+2005-04-28: Christian Hentschel <[email protected]>
+ - Fix segfault at route del.
*/

#include <tui.h>
@@ -183,7 +187,6 @@

                        if (route->network == r2->network &&
                            route->netmask == r2->netmask) {
                                found=1;
-                               list_del(&r2->entry);
                                talloc_free(r2);
                                nfsim_log(LOG_UI, "route removed");
                                break;
Signature · 1 line
Christian Hentschel <[email protected]>
#1 lore raw
Quoted 1 line · Christian Hentschel

This patch fixes segfault at route del command.

How is this patch supposed to fix the problem? AFAICT you no longer delete the route from the list, but still free it's data.

Please explain.

Signature · 5 lines
- Harald Welte <[email protected]>                 http://netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie
#2 lore raw

Yes, sorry for that. I'm quite stupid some times.

There is an extra call to list_del() in tool/route.c at line 186. when someone's trying to delete a route.
ie. route del 192.168.0.0/24

The implementation leaves core/ipv4.c at line 38, the "destruction" of the route after calling talloc_free().
here's that code:

static int destroy_route(void *r)

{
	struct ipv4_route *route = r;
	list_del(&route->entry);
	return 0;
}

So this extra call leaves wild pointers causing the second call to segfault.
This patch fixes this segfault, leaving the destruction of the route at line 38 of core/ipv4.c

Regards
Christian.

Quoted 8 lines · Harald Welte
Quoted 1 line · Christian Hentschel

This patch fixes segfault at route del command.

How is this patch supposed to fix the problem? AFAICT you no longer delete the route from the list, but still free it's data.

Please explain.

Signature · 1 line
Christian Hentschel <[email protected]>
route.c +0 -1
Index: tools/route.c
===================================================================
@@ -183,7 +183,6 @@
 			if (route->network == r2->network &&
 			    route->netmask == r2->netmask) {
 				found=1;
-				list_del(&r2->entry);
 				talloc_free(r2);
 				nfsim_log(LOG_UI, "route removed");
 				break;