From patchwork Fri Oct 27 16:55:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Mashak X-Patchwork-Id: 831415 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="VlAEksJA"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yNqkf28Dnz9t39 for ; Sat, 28 Oct 2017 03:55:38 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752396AbdJ0Qzg (ORCPT ); Fri, 27 Oct 2017 12:55:36 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:55932 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751770AbdJ0Qzf (ORCPT ); Fri, 27 Oct 2017 12:55:35 -0400 Received: by mail-io0-f196.google.com with SMTP id p186so14011652ioe.12 for ; Fri, 27 Oct 2017 09:55:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=ChBpUOxRc0v2kUhQvc/FQzh8dvd8/5jEolBMbYqTxvg=; b=VlAEksJA/SSpEstMv9INL2gmzrDbi4/mFxz22XgDjYWi5mH61aQw0vg36VHMNPaajs P2+h8D/xaSv3Pr4rDo2JvmgRGiV3Q32bGfeMUwmfDyyMbtcywDVJ+NWs+PbAGr7KW8Xw pcJuPx/k/vF0k5zlcQdwhB0KKO205URxXxwnwG6fp/jbsn99xFkD33uh3tgxBwVejZwr DPliDSqIgyMvC0zRK2vSSeKkVR2EBYHv88ddMTPZ5RsHJC0Ylv5xRHqGSxpaWkR5gOXM KhgQ2y0Lfqd/2KMz0w2dscwQyMlRjOs0JMKJv2OOb3WuhRykQYkeceycHMr339QH0qHP 2Fug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ChBpUOxRc0v2kUhQvc/FQzh8dvd8/5jEolBMbYqTxvg=; b=CyjNlWhZYCfDDncg/UqFociJP1bmTDxzIV4fwnExnMRBxCil9azw0hnRvekYJ8U5ad RbL54l9NqdpkuPEHo1O0wmgghn70+dJSqGMpm4fIiF+oXLIUA+fSbbR+qBRVNr9hkigl mvldfWnd3c7izcj6QA6rpCjvR8QbJhwqU7bPTeY4rZUy65D/gJzPAcWOjYfrQ0k7AAVS FFqD+C1+SgWUsJozPMjT8TPowJVdOYpUjLUOCOH+DjKoeZJStWd+UGoGNsiLcZg8dhhp gtOLoSCF2Tp7BiyTRMVHjcRzCJpPGn4ANEl0EEEVkB5NLQlAOf7YFTgmnPvLkjiQuIn6 oBPQ== X-Gm-Message-State: AMCzsaWyfdHLQTS/vPuOpCm5Fsb1B7LjShTP6ZLfP1HAmiEzf7MnZBHc DJOS2QandppZKEgmk8nJvIfAFLv1 X-Google-Smtp-Source: ABhQp+SPYsQj1ilDU1+Y1vKa9rrdae4Fp2mUiZ2mNVmKWwy5E+Mo5YiS1k7xPxb/hV2GrAVO3aVapQ== X-Received: by 10.36.179.1 with SMTP id e1mr1486909itf.27.1509123334819; Fri, 27 Oct 2017 09:55:34 -0700 (PDT) Received: from mojatatu.com ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id 5sm3620769ion.46.2017.10.27.09.55.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Oct 2017 09:55:34 -0700 (PDT) From: Roman Mashak To: stephen@networkplumber.org Cc: netdev@vger.kernel.org, jhs@mojatatu.com, Roman Mashak Subject: [PATCH iproute2 1/1] ip netns: use strtol() instead of atoi() Date: Fri, 27 Oct 2017 12:55:27 -0400 Message-Id: <1509123327-31751-1-git-send-email-mrv@mojatatu.com> X-Mailer: git-send-email 1.9.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use strtol-based API to parse and validate integer input; atoi() does not detect errors and may yield undefined behaviour if result can't be represented. Signed-off-by: Roman Mashak --- ip/ipnetns.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ip/ipnetns.c b/ip/ipnetns.c index afb4978..96da040 100644 --- a/ip/ipnetns.c +++ b/ip/ipnetns.c @@ -711,7 +711,8 @@ static int netns_set(int argc, char **argv) return -1; } name = argv[0]; - nsid = atoi(argv[1]); + if (get_integer(&nsid, argv[1], 0)) + invarg("Invalid \"netnsid\" value\n", argv[1]); snprintf(netns_path, sizeof(netns_path), "%s/%s", NETNS_RUN_DIR, name); netns = open(netns_path, O_RDONLY | O_CLOEXEC);