From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by dpdk.org (Postfix) with ESMTP id D337A1BBD6 for ; Thu, 20 Dec 2018 18:07:15 +0100 (CET) Received: by mail-wm1-f68.google.com with SMTP id g67so3022870wmd.2 for ; Thu, 20 Dec 2018 09:07:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WmIS9ZkPNRB9weAc5xdzDHhrqdkitG4bISd9+SLc1rA=; b=KeDconFEkz8Fk9Oo6de9lUGOHYaYL9LZMcaMYEnAPQ9s9hgDEbFjkTOpQ1OD7lQh4O 1J12sxBv0LAjM5VJs45fpXD93AYHaA1vkv70pTKBPMcPjjPKJxgrJcUxwpIeIxWxv09c mZddYgY96Cb4VOpdVWyPU5SZb6CddtudiernbTc5SMKAHrffrbzgAl28MLQlQZwC/MZg RiDIVrb5mdFROK0ahTvAP4P9OU76hT3rstL5XQayfUqWfmfQgI/zMZfFyWfpew39Lzaz eP8yDld7p5PvVy71qb6KistoJsHopULDpoPVuPEqmDLRCUONpk8fVNld71S6qj0pAM4J 4l+A== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=WmIS9ZkPNRB9weAc5xdzDHhrqdkitG4bISd9+SLc1rA=; b=jmeYqeodLn2M1lMx7+rqs6DwvQqnFdQrCItgpgFaE4JLhqKYMSroc5aGsJICMFBVxG n5d6fLU+vTlD+8z1YOZ2qHV83k/IeK3IJ+XuV6cQdkeY+kO3h/hcYwEx9jUsIb16RrTb ujrsTRvgPQTuLSW9i//o3NYplXWXj/Yk8YDaCyeSwBimtNWAINKIaf9Q7FWeKHJcbryg nmVS915QEY9UA16vCgP0oyY26F6UFCftKBGarX1PK3PA7+aeQN8MWtuqt9RQmgrsjD+x oSa5duvAJmPenUoAvaCXZ0vI6dcgNkLG461ep+VhPg9y3rv2s7CbSADpjI4UbuScPzDT bykw== X-Gm-Message-State: AA+aEWYDrjdsIFxE2VKDzEdCTeiXj2+dwD6acDI8EBrnCv6LZ7Z7xGlu jxc15n0gqooCxD5EIpuqTqEVGOKFu9c= X-Google-Smtp-Source: AFSGD/VvWhacYMkOOtyT8EITeqofURETrjR5Xg017tmCYln+2Yr/GM0c7HaZyVcg9QsG7rrjap8uRA== X-Received: by 2002:a1c:b687:: with SMTP id g129mr12097342wmf.59.1545325635081; Thu, 20 Dec 2018 09:07:15 -0800 (PST) Received: from bidouze.dev.6wind.com. (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id n5sm11951688wrr.94.2018.12.20.09.07.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 09:07:14 -0800 (PST) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 20 Dec 2018 18:06:40 +0100 Message-Id: X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v1 1/8] option: use bare option string as name X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Dec 2018 17:07:16 -0000 Current options name can be passed with arbitrary format. Force the use of "--" prefix and thus POSIX long options format. This restricts the ability to introduce surprising options and will help future additional checks. Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/rte_option.c | 6 +++++- lib/librte_telemetry/rte_telemetry.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/rte_option.c b/lib/librte_eal/common/rte_option.c index 088e0fd23..3fbc13a6a 100644 --- a/lib/librte_eal/common/rte_option.c +++ b/lib/librte_eal/common/rte_option.c @@ -20,9 +20,13 @@ static struct rte_option *option; int rte_option_parse(const char *opt) { + if (strlen(opt) <= 2 || + strncmp(opt, "--", 2)) + return -1; + /* Check if the option is registered */ TAILQ_FOREACH(option, &rte_option_list, next) { - if (strcmp(opt, option->opt_str) == 0) { + if (strcmp(&opt[2], option->opt_str) == 0) { option->enabled = 1; return 0; } diff --git a/lib/librte_telemetry/rte_telemetry.c b/lib/librte_telemetry/rte_telemetry.c index 016431f12..3080bb715 100644 --- a/lib/librte_telemetry/rte_telemetry.c +++ b/lib/librte_telemetry/rte_telemetry.c @@ -1798,7 +1798,7 @@ rte_telemetry_json_socket_message_test(struct telemetry_impl *telemetry, int fd) int telemetry_log_level; static struct rte_option option = { - .opt_str = "--telemetry", + .opt_str = "telemetry", .cb = &rte_telemetry_init, .enabled = 0 }; -- 2.19.1