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 0B7D6A034D; Wed, 5 Jan 2022 19:01:57 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6166B40E50; Wed, 5 Jan 2022 19:01:57 +0100 (CET) Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by mails.dpdk.org (Postfix) with ESMTP id 2803040E03 for ; Wed, 5 Jan 2022 19:01:56 +0100 (CET) Received: by mail-pj1-f51.google.com with SMTP id g11-20020a17090a7d0b00b001b2c12c7273so3805503pjl.0 for ; Wed, 05 Jan 2022 10:01:56 -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=irhfJAfzBduThNA9m2ZPnttXoehaNt4Ki3vnrhSTuVU=; b=yJODoL6kNLH4VqzZJfVF4mc3slcnU7zXikpprEaLzBRWZG+ZZvIWetL5WziUJ5Kwj9 XPmCu1Wl1xDBnxCwTVvnUVeCyOPqkoJkupa2wNVn0zuIrMeOL0G81e+42hoKAdJLiC6M qJQ/DsMd0jVZ1xa5VtVmIwJginZeMQUJ/VFn5C8EaTMRbJ5nIo+CyNjPmL8EgS6wPzAw 2skOu5QaEqcIoEM5QDPnWKTzDYoyo9t5a52uwvFfKAwGmuFHijaio1NNhbXE5MkESUp+ Qxxj32gBGZBfwlljMW7iA6l70Sgkb3EvQ+6zL5HP/k2IqEn8IlRyI8RzjqQ+M1ul2p0A gigg== 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=irhfJAfzBduThNA9m2ZPnttXoehaNt4Ki3vnrhSTuVU=; b=eN1CR0LUW5URfOLs5gFibaznTSxhpcLzv1AFwessb83rDT1m2G8s97QqHcnxxmUuE1 s3o71UU0m5wNYtgMU5OtEpLJaFKtsdKAAPCJENm08ZuqUMj2d/VaPT2CPgCspFclODnU NovnXZ5Pqobe2cOsDlcY+VnwXsuXnE6sPM4aKXjJghiBtMsPtqP1iY683kzcnXHtpk+r YFFrwi/wLy0c7tej1OuB3KgJ3t9TXi5C3mTNzMlmwKCqaOlnh9t2e3cRKsBY+C1682tt zgJo/YetRUza70hPRMCxAEBp291zRaS2HcO81ckKuZvd1duf918A8BkICBa8aSKssxO9 uSeg== X-Gm-Message-State: AOAM531vCnyr+c67zKLbg51h8xKVgHOMaSxIsv5/KU8jEU1qwjbBbkAp hNEx1+i2qcysfpbrcXN+BV6fCqCFUTS7Qw== X-Google-Smtp-Source: ABdhPJz2QNwez0GP3Yl2DapneCkdcmJ9Zy/G7KFjGK5dByHwop4LYVBp2hTJGtOKTE47ica6fa6g8A== X-Received: by 2002:a17:90a:be03:: with SMTP id a3mr3543455pjs.152.1641405715229; Wed, 05 Jan 2022 10:01:55 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id l145sm45802261pfd.117.2022.01.05.10.01.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 10:01:54 -0800 (PST) From: Stephen Hemminger To: =?UTF-8?q?Morten=20Br=C3=B8rup?= Cc: dev@dpdk.org, Stephen Hemminger Subject: [RFC] eal: remove size for eal_set_runtime_dir Date: Wed, 5 Jan 2022 10:01:53 -0800 Message-Id: <20220105180153.73311-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D86DB1@smartserver.smartshare.dk> References: <98CBD80474FA8B44BF855DF32C47DC35D86DB1@smartserver.smartshare.dk> 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. Signed-off-by: Stephen Hemminger Suggested-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 1c4c4dd585d0..62a9d7a198db 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 80ffe1c7f9d8..a73ff75f65c9 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -135,7 +135,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.30.2