From mboxrd@z Thu Jan 1 00:00:00 1970 From: Serhey Popovych Subject: [PATCH iproute2 2/3] iplink: Process "alias" parameter correctly Date: Mon, 18 Dec 2017 20:54:07 +0200 Message-ID: <1513623248-7689-3-git-send-email-serhe.popovych@gmail.com> References: <1513623248-7689-1-git-send-email-serhe.popovych@gmail.com> To: netdev@vger.kernel.org Return-path: Received: from mail-lf0-f66.google.com ([209.85.215.66]:42112 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933035AbdLRSzD (ORCPT ); Mon, 18 Dec 2017 13:55:03 -0500 Received: by mail-lf0-f66.google.com with SMTP id e30so2039078lfb.9 for ; Mon, 18 Dec 2017 10:55:02 -0800 (PST) Received: from tuxracer.localdomain ([2a01:6d80::195:20:96:53]) by smtp.gmail.com with ESMTPSA id y26sm1916932lfk.85.2017.12.18.10.55.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Dec 2017 10:55:00 -0800 (PST) In-Reply-To: <1513623248-7689-1-git-send-email-serhe.popovych@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: Do not stop parameters processing after "alias" parameter: it might not be a last one. Seems copy pasted from "type" parameter code. Check it's length does not exceed IFALIASZ - 1. Better we warn than get RTNL error. Signed-off-by: Serhey Popovych --- ip/iplink.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ip/iplink.c b/ip/iplink.c index 4f9c169..4c96711 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -770,11 +770,12 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, argc--; argv++; break; } else if (matches(*argv, "alias") == 0) { + len = strlen(*argv); + if (len >= IFALIASZ) + invarg("alias too long\n", *argv); NEXT_ARG(); addattr_l(&req->n, sizeof(*req), IFLA_IFALIAS, - *argv, strlen(*argv)); - argc--; argv++; - break; + *argv, len); } else if (strcmp(*argv, "group") == 0) { NEXT_ARG(); if (*group != -1) -- 1.7.10.4