public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Denys Fedoryshchenko <denys@visp•net.lb>
To: Stephen Hemminger <shemminger@linux-foundation•org>
Cc: netdev@vger•kernel.org
Subject: few more fixes for iproute2/m_ipt
Date: Wed, 6 Aug 2008 00:42:53 +0300	[thread overview]
Message-ID: <200808060042.53503.denys@visp.net.lb> (raw)

[-- Attachment #1: Type: text/plain, Size: 612 bytes --]

Comments:
1)optind according iptables sources have to be set to 0. If it is set to 1, in 
batch it will mess up things. Also in iptables sources i notice that ->tflags 
and ->used need to be reset.

2)Since target->t = fw_calloc(1, size); allocated memory in function build_st, 
it have to be freed at the end, or in batch we will have memory leak. TODO: 
Probably it must be freed in all "return -1" cases in parse_ipt after 
build_st. About this i am not sure, up to Stephen.

3)lname and new_name was malloc'ed, but not freed

Point 1 fix is critical, since without it m_ipt crashing iproute2 in batch 
mode.

[-- Attachment #2: m_ipt_fix3.patch --]
[-- Type: text/x-diff, Size: 891 bytes --]

diff -Naur iproute2-original/tc/m_ipt.c iproute2-patched/tc/m_ipt.c
--- iproute2-original/tc/m_ipt.c	2008-08-05 19:15:56.000000000 +0000
+++ iproute2-patched/tc/m_ipt.c	2008-08-05 21:39:49.000000000 +0000
@@ -277,6 +277,8 @@
 		if (!handle) {
 			fputs(dlerror(), stderr);
 			printf("\n");
+			free(l_name);
+			free(new_name);
 			return NULL;
 		}
 	}
@@ -292,12 +294,16 @@
 					fputs(error, stderr);
 					fprintf(stderr, "\n");
 					dlclose(handle);
+					free(l_name);
+					free(new_name);
 					return NULL;
 				}
 			}
 		}
 	}
 
+	free(l_name);
+	free(new_name);
 	return m;
 }
 
@@ -512,8 +518,15 @@
 	*argc_p = rargc - iargc;
 	*argv_p = argv;
 
-	optind = 1;
+	optind = 0;
 	free_opts(opts);
+	/* Clear flags if target will be used again */
+        m->tflags=0;
+        m->used=0;
+	/* Free allocated memory */
+        if (m->t)
+            free(m->t);
+
 
 	return 0;
 

             reply	other threads:[~2008-08-05 21:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-05 21:42 Denys Fedoryshchenko [this message]
2008-08-06 10:04 ` few more fixes for iproute2/m_ipt jamal
2008-08-06 10:21   ` Denys Fedoryshchenko
2008-08-06 11:04     ` jamal
2008-08-06 11:26       ` Denys Fedoryshchenko
2008-08-06 12:46         ` jamal
2008-08-06 12:50           ` Denys Fedoryshchenko
2008-08-06 12:55             ` jamal
2008-08-06 12:56               ` Denys Fedoryshchenko
2008-08-06 12:59               ` Denys Fedoryshchenko
2008-08-06 13:17                 ` jamal
2009-01-07  3:43 ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200808060042.53503.denys@visp.net.lb \
    --to=denys@visp$(echo .)net.lb \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=shemminger@linux-foundation$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox