Subject: [PATCH 1/2] Initialize arguments to iplink_parse() by default

From: Sergey Popovich <[email-masked]>
Date: Wed, 11 Dec 2013 14:25:10 +0200

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 <[email-masked]>
---
 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