From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f170.google.com (mail-wr0-f170.google.com [209.85.128.170]) by dpdk.org (Postfix) with ESMTP id 54F0E5598 for ; Thu, 3 Aug 2017 17:08:49 +0200 (CEST) Received: by mail-wr0-f170.google.com with SMTP id v105so6926695wrb.0 for ; Thu, 03 Aug 2017 08:08:49 -0700 (PDT) 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; bh=gF8ojM3pFuRjmhFZjNkjQti0yREJ3CwZt0eUmOuwZRQ=; b=xg+3Is4nttX1Uw5dm1O/WWt+iW/WkYgiRmDW4E8zlfuFsf/bRXc8rNgsTqc2fX15Kp T3UIYKQCkcAQQYcXnqyghMJzlh5ZvDaQezcFJ76/dtG7GyYyaK/AcK9NLTWJmgFyhH9O aiAjxVAADDFMPxi/9DHtKuA/1hCBa4Cloo9hld0ablJetO0gxVxRxevma9TROpyW+0fh aYiNsPQ4rEhe7HeNz8NDvHJ8KvTmqotLsGoCLCxmp1AATevH+IMBtVQErBpgufXG9EzF VatMA0/oen1ZDlLvyrL1pNiCF+bPuda6ofIPvLxfCv741BrACZmFAagsYLH3S6ZtxQVd gQVg== 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; bh=gF8ojM3pFuRjmhFZjNkjQti0yREJ3CwZt0eUmOuwZRQ=; b=bptEmGmUVrt8q6EJg2sBMBmOMi6AcLmnjz+ctu4eah7qp6YvVfRMH3QCZWx0OMsWAG dbSM71QtKfvcjlKt1DmFQMFESpa4XORHLCPWcW7A912beufkIGoaPyB9EV522maB32St rW/9NcAS3SheZ+dSu9kX8rDnGOqm0ZdZUsXR5xKx4om7Pskh9SyJ5xwwC9hMrBi4fjWw d2Vw04gSizTar69k1HVGxB8/l8lTbjmusDVg9+xczKBTMEUDboYYI6oQOTIXH+CiSXz2 om53q/dM0597nfKGq3hIn/+BXt0SEWmLkZiN07hnRLHqEPiFDcoS0Z4tM/K5sZ6+DOUF +Eyw== X-Gm-Message-State: AIVw112nzV0QEre/WgBosI9E3YYQV4VGLEYXreFKF89fb7v8E9t11naQ D41oUs7g7YYNBoUBdb0= X-Received: by 10.223.135.38 with SMTP id a35mr1623217wra.78.1501772928636; Thu, 03 Aug 2017 08:08:48 -0700 (PDT) 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 53sm2217250wry.31.2017.08.03.08.08.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Aug 2017 08:08:47 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 3 Aug 2017 17:08:34 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2] net/failsafe: fix blank line parsing 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, 03 Aug 2017 15:08:49 -0000 When the output of an exec() slave definition is only a single newline character, the fail-safe currently fails to parse the device with the value returned by the rte_devargs library. This behavior is incorrect, because the fail-safe should make a difference between the absence of a device, and an erroneous device declaration. Fix the output sanitization in the case where no newline was at its end and detect the special case of an absent device. The correct error code is then returned. Fixes: a0194d828100 ("net/failsafe: add flexible device definition") Signed-off-by: Gaetan Rivet --- This patch depends on: net/failsafe: fix for missing pclose after popen http://dpdk.org/ml/archives/dev/2017-August/072429.html v2: - Remove useless, unposix use of strnlen drivers/net/failsafe/failsafe_args.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/failsafe/failsafe_args.c b/drivers/net/failsafe/failsafe_args.c index 3f92a77..1f22416 100644 --- a/drivers/net/failsafe/failsafe_args.c +++ b/drivers/net/failsafe/failsafe_args.c @@ -101,10 +101,11 @@ fs_parse_device(struct sub_device *sdev, char *args) static void fs_sanitize_cmdline(char *args) { - size_t len; + char *nl; - len = strnlen(args, DEVARGS_MAXLEN); - args[len - 1] = '\0'; + nl = strrchr(args, '\n'); + if (nl) + nl[0] = '\0'; } static int @@ -149,6 +150,10 @@ fs_execute_cmd(struct sub_device *sdev, char *cmdline) goto ret_pclose; } fs_sanitize_cmdline(output); + if (output[0] == '\0') { + ret = -ENODEV; + goto ret_pclose; + } ret = fs_parse_device(sdev, output); if (ret) { ERROR("Parsing device '%s' failed", output); -- 2.1.4