All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Popovich <popovich_sergei@mail.ru>
To: netdev@vger.kernel.org
Subject: [PATCH 1/2] Initialize arguments to iplink_parse() by default
Date: Wed, 11 Dec 2013 14:25:10 +0200	[thread overview]
Message-ID: <4467313.PgxQL6MHJm@tuxracer> (raw)
In-Reply-To: <cover.1386764590.git.popovich_sergei@mail.ru>

Be consistent when dealing with arguments passed
to iplink_parse() by initializing to default values.

This fixes crash when ip-link(8) invoced with command:

  ip link add dev veth1a type veth peer

Signed-off-by: Sergey Popovich <popovich_sergei@mail.ru>
---
 ip/iplink.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/ip/iplink.c b/ip/iplink.c
index 58b6c20..9735c54 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -299,6 +299,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
 	int numtxqueues = -1;
 	int numrxqueues = -1;
 
+	*name = *type = *link = *dev = NULL;
 	*group = -1;
 	ret = argc;
 
@@ -498,15 +499,11 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
 
 static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
 {
-	int len;
-	char *dev = NULL;
-	char *name = NULL;
-	char *link = NULL;
-	char *type = NULL;
+	char *name, *type, *link, *dev;
 	int group;
 	struct link_util *lu = NULL;
 	struct iplink_req req;
-	int ret;
+	int len, ret;
 
 	memset(&req, 0, sizeof(req));
 
-- 
1.7.10.4

  parent reply	other threads:[~2013-12-11 12:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1386764590.git.popovich_sergei@mail.ru>
2013-12-11 12:25 ` [PATCH 2/2] Handle netdev group for veth peer too Sergey Popovich
2013-12-11 12:25 ` Sergey Popovich [this message]
2013-12-20 16:27   ` [PATCH 1/2] Initialize arguments to iplink_parse() by default 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=4467313.PgxQL6MHJm@tuxracer \
    --to=popovich_sergei@mail.ru \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.