From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AC451A034F; Wed, 9 Feb 2022 07:54:14 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B4C584114F; Wed, 9 Feb 2022 07:54:09 +0100 (CET) Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by mails.dpdk.org (Postfix) with ESMTP id 7DBF1410F3 for ; Wed, 9 Feb 2022 07:54:08 +0100 (CET) Received: by mail-pj1-f52.google.com with SMTP id m7so1371992pjk.0 for ; Tue, 08 Feb 2022 22:54:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=83ixOjSDKJJF6/vspr4uWMVGJOsR3WgL3HUW3Yg8L3s=; b=nsVCow7Ezu/z7yP+f1yHvmDApKSvXDh2ZMbb5Yozh5C1vhhtqJP8KRfeh3v3Z10fNI 55kEhmfkhAeWIZfby4N7BilKkHz9/FoS4s/XsZpX/eMpcRQMKaM7Xlxpcofhp5tLktu6 mbRXehBtKIQ5cabgXPenHTjnM6pFZQCc1vCrljhDhmYn0KfK4QfySDwS4oe4vpdYe3Y1 elfuZOEGEuf0uH1GTTfN4/aSIpe0KrUfdFTH1aARDzqsHmJjVA/yGG0iKlLm512juGgO iF4nJLHyCUFT5EZNZ2gAyF+Xj2fCul2XvUQm7wduFNeLoUk7lRb61gor7mMMNyOj3B7U 6ifA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=83ixOjSDKJJF6/vspr4uWMVGJOsR3WgL3HUW3Yg8L3s=; b=cZ6Y1XqUscN0YE1dFP7H0MwR6Jj85JmR0wfXLmpxjg7xGhzAP21ok7MR/GZyN4Lroc f+T+NixzkAzeYRjTAZkidIl8Pg65MwDGisEbJVVUvMQiZxGDCFqPgCvTxe27BI5HC9LW SFz8Ex9DEn8RfoFP3BJvg2+sqsxbpp1tuHUwrc8O2dhimoI3+NN7zyQwZiKGvtZX4RXP bBipTvNFrlWhKIoGTt1s6z/xN1/p6Fdk31J8IbhEkLBUNDk52UVBm5c+ujyo3/W5MOMU /Jq8Y0Gi8Jr9sSu4vVXfCg2zzElcQSyORyh32kN2H09SgZVDQKpAtgdUjUoiCU0+mw7M pAZg== X-Gm-Message-State: AOAM533y9oU/g71N+q31OtTxXJWmGvvP6eX1tW5j7AGp8ei/pM+C8Die CMXdpAqwKsUUkhiueoXBOkcdT3mE3VmX3F4V X-Google-Smtp-Source: ABdhPJwpSlb/IVfxRnYQcW1DvWD7dJHLhUxsnrFZPdRAMI6NNhEkvDN01wTJrGnbq/1N6KaTm8iZRw== X-Received: by 2002:a17:902:ed82:: with SMTP id e2mr773118plj.55.1644389647383; Tue, 08 Feb 2022 22:54:07 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id oa5sm5208892pjb.0.2022.02.08.22.54.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 22:54:06 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , =?UTF-8?q?Morten=20Br=C3=B8rup?= Subject: [PATCH v3 1/3] eal: remove size for eal_set_runtime_dir Date: Tue, 8 Feb 2022 22:54:01 -0800 Message-Id: <20220209065403.168475-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220209065403.168475-1-stephen@networkplumber.org> References: <20211223233907.181033-1-stephen@networkplumber.org> <20220209065403.168475-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The size argument to eal_set_runtime_dir is useless and was being used incorrectly in strlcpy. It worked only because all callers passed PATH_MAX which is same as sizeof the destination runtime_dir. Note: this is an internal API so no user exposed change. Signed-off-by: Stephen Hemminger Reviewed-by: Morten Brørup --- lib/eal/common/eal_common_config.c | 7 ++----- lib/eal/common/eal_private.h | 4 +--- lib/eal/freebsd/eal.c | 2 +- lib/eal/linux/eal.c | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/eal/common/eal_common_config.c b/lib/eal/common/eal_common_config.c index 6d19aadb2057..3cef43a4f706 100644 --- a/lib/eal/common/eal_common_config.c +++ b/lib/eal/common/eal_common_config.c @@ -29,12 +29,9 @@ rte_eal_get_runtime_dir(void) } int -eal_set_runtime_dir(char *run_dir, size_t size) +eal_set_runtime_dir(const char *run_dir) { - size_t str_size; - - str_size = strlcpy(runtime_dir, run_dir, size); - if (str_size >= size) { + if (strlcpy(runtime_dir, run_dir, PATH_MAX) >= PATH_MAX) { RTE_LOG(ERR, EAL, "Runtime directory string too long\n"); return -1; } diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h index 36bcc0b5a492..734f1f334b69 100644 --- a/lib/eal/common/eal_private.h +++ b/lib/eal/common/eal_private.h @@ -681,13 +681,11 @@ eal_mem_set_dump(void *virt, size_t size, bool dump); * * @param run_dir * The new runtime directory path of DPDK - * @param size - * The size of the new runtime directory path in bytes. * @return * 0 on success, (-1) on failure. */ int -eal_set_runtime_dir(char *run_dir, size_t size); +eal_set_runtime_dir(const char *run_dir); /** * Get the internal configuration structure. diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index a1cd2462db1b..503e276dc27f 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -123,7 +123,7 @@ eal_create_runtime_dir(void) return -1; } - if (eal_set_runtime_dir(run_dir, sizeof(run_dir))) + if (eal_set_runtime_dir(run_dir)) return -1; return 0; diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 9c8395ab14d0..e37372ac7305 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -137,7 +137,7 @@ eal_create_runtime_dir(void) return -1; } - if (eal_set_runtime_dir(run_dir, sizeof(run_dir))) + if (eal_set_runtime_dir(run_dir)) return -1; return 0; -- 2.34.1