From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAC21C433EF for ; Thu, 14 Oct 2021 18:50:40 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1A98361056 for ; Thu, 14 Oct 2021 18:50:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1A98361056 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6F119837C6; Thu, 14 Oct 2021 20:50:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="DOp9chUL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6490B83649; Thu, 14 Oct 2021 20:49:07 +0200 (CEST) Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E8171836BB for ; Thu, 14 Oct 2021 20:48:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12c.google.com with SMTP id x1so4565512ilv.4 for ; Thu, 14 Oct 2021 11:48:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=coLkTy6smhrq3XyRoTefCOBeD8UHoxJBTb6Eo7C75Zo=; b=DOp9chUL6S45hlqay3UIZF4toMuQEWcucM44M7+Sa03nKG7e0tpMGv/yMSTlKcBbHw aZV0O3+LdeqAAt9gE025fMHiJJ03sJm+hiBrbnMp0se6nLYEISnnmaQa6rmFCe2e9gS4 2Lre9xqiXN53DAfPS8F6czNNWrAZ3q33z1jHs= 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=coLkTy6smhrq3XyRoTefCOBeD8UHoxJBTb6Eo7C75Zo=; b=XVw3wGl+E/rF+kwm6dlphRfp+hcHw7V1s3vhBvUFMa4iigI/pEs//IFvwNMnAPyiCj cF52ye3JtrBRMyzE1/J3LXnGD58mORz72ODaIbEigZ/pjHO9lEr82ZsHM8RKcTbZZzKs 3Z+OkA+m8f1X+qIValIEgd2Q+J+rZzmPMZ/7ekPwccQgKnMyOYi5SY0tiDlEv0wJxif1 yKn0dSnPPmXrK7tGZDnAfA1njEZvLe/Y/m4GzYvmw26LZ8Trov7zSlbqJAJHDc8T2Nzv P1m3lViouliNgeZW6iOH9XRJR6RBRYK4ByUI/fmhfn22+zF0hAkhFfCsbfCML3IPxDvZ 8Fug== X-Gm-Message-State: AOAM532PjuygJ0xyyt5g+3Q3DkMfc9zZCSih6NSczkX+uJeybR2RyxzQ cxjC8hSgAXhY96dLRRLu9QDjptJvhdFd6A== X-Google-Smtp-Source: ABdhPJxV4wFkUdx0bmDXzqoZ+2h/OEtNPiPpL6yzc2X1eo5zBMkCpmsH/9V/98odhQGLM69UjmB8OA== X-Received: by 2002:a05:6e02:1be8:: with SMTP id y8mr536269ilv.24.1634237314292; Thu, 14 Oct 2021 11:48:34 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w15sm1697625ill.23.2021.10.14.11.48.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 11:48:33 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Patrice Chotard , Artem Lapkin , Tom Rini , Joe Hershberger , Heinrich Schuchardt , Peter Hoyes , Simon Glass Subject: [PATCH v3 12/18] pxe: Drop get_bootfile_path() Date: Thu, 14 Oct 2021 12:48:05 -0600 Message-Id: <20211014124803.v3.12.Iabd27f61cd3bf528f835dea68f0c3997e85be0d0@changeid> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog In-Reply-To: <20211014184811.482560-1-sjg@chromium.org> References: <20211014184811.482560-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean This function no longer makes sense, since it is pretty easy to prepend the boot directory to the filename. Drop it and update its only caller. Signed-off-by: Simon Glass --- (no changes since v1) boot/pxe_utils.c | 53 +++++---------------------------------------- include/pxe_utils.h | 3 ++- 2 files changed, 7 insertions(+), 49 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index c04be110ea4..f36f1f8a60c 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -64,47 +64,6 @@ int format_mac_pxe(char *outbuf, size_t outbuf_len) return 1; } -/** - * get_bootfile_path() - Figure out the path of a file to read - * - * Copies the boot directory into the supplied buffer. If there is no boot - * directory, set it to "" - * - * @ctx: PXE context - * @file_path: File path to read (relative to the PXE file) - * @bootfile_path: Place to put the bootfile path - * @bootfile_path_size: Size of @bootfile_path in bytes - * @allow_abs_path: true to allow an absolute path (where @file_path starts with - * '/', false to return an empty path (and success) in that case - * Returns 1 for success, -ENOSPC if bootfile_path_size is to small to hold the - * resulting path - */ -static int get_bootfile_path(struct pxe_context *ctx, const char *file_path, - char *bootfile_path, size_t bootfile_path_size, - bool allow_abs_path) -{ - size_t path_len = 0; - - /* Only syslinux allows absolute paths */ - if (file_path[0] == '/' && allow_abs_path) - goto ret; - - path_len = strlen(ctx->bootdir); - if (bootfile_path_size < path_len + 1) { - printf("bootfile_path too small. (%zd < %zd)\n", - bootfile_path_size, path_len); - - return -ENOSPC; - } - - strncpy(bootfile_path, ctx->bootdir, path_len); - - ret: - bootfile_path[path_len] = '\0'; - - return 1; -} - /** * get_relfile() - read a file relative to the PXE file * @@ -124,15 +83,13 @@ static int get_relfile(struct pxe_context *ctx, const char *file_path, size_t path_len; char relfile[MAX_TFTP_PATH_LEN + 1]; char addr_buf[18]; - int err; - err = get_bootfile_path(ctx, file_path, relfile, sizeof(relfile), - ctx->allow_abs_path); - if (err < 0) - return err; + if (file_path[0] == '/' && ctx->allow_abs_path) + *relfile = '\0'; + else + strncpy(relfile, ctx->bootdir, MAX_TFTP_PATH_LEN); - path_len = strlen(file_path); - path_len += strlen(relfile); + path_len = strlen(file_path) + strlen(relfile); if (path_len > MAX_TFTP_PATH_LEN) { printf("Base path too long (%s%s)\n", relfile, file_path); diff --git a/include/pxe_utils.h b/include/pxe_utils.h index 543d0245c8a..8b50f2e6861 100644 --- a/include/pxe_utils.h +++ b/include/pxe_utils.h @@ -202,7 +202,8 @@ int format_mac_pxe(char *outbuf, size_t outbuf_len); * @allow_abs_path: true to allow absolute paths * @bootfile: Bootfile whose directory loaded files are relative to, NULL if * none - * @return 0 if OK, -ENOMEM if out of memory + * @return 0 if OK, -ENOMEM if out of memory, -E2BIG if bootfile is larger than + * MAX_TFTP_PATH_LEN bytes */ int pxe_setup_ctx(struct pxe_context *ctx, struct cmd_tbl *cmdtp, pxe_getfile_func getfile, void *userdata, -- 2.33.0.1079.g6e70778dc9-goog