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 X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AAF1C4338F for ; Thu, 19 Aug 2021 03:49:00 +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 823376109E for ; Thu, 19 Aug 2021 03:48:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 823376109E 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 31A3683212; Thu, 19 Aug 2021 05:47:14 +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="eE9oTGh1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0649B831C8; Thu, 19 Aug 2021 05:46:36 +0200 (CEST) Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) (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 7F2AC83168 for ; Thu, 19 Aug 2021 05:46:26 +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-ot1-x332.google.com with SMTP id w22-20020a056830411600b0048bcf4c6bd9so6984255ott.8 for ; Wed, 18 Aug 2021 20:46:26 -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=7zMW1Dv3noDA+37ijDEbjQqsx2ZV1NIfBAhfVBZ/H7U=; b=eE9oTGh162u7EOEcPscnj08pz095+rIgJYKDcm0aAON80U1uR84ka4VtdehP9zcTJH pGBbVX0cVJtt8i3N54x732uV86FbbQjZARV/ihlu4HmbL2AY1DMLhyavuqZ9vtwBVs/h fOTPk9uraLTmh6fLpVlZwAz4p/yEDwq8zKtEk= 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=7zMW1Dv3noDA+37ijDEbjQqsx2ZV1NIfBAhfVBZ/H7U=; b=KJwCvLkkBwaS3x6luFcDWjy/4N5OoDY2mGEoeSBZIORUL6V7Q1qJuRyg5LKJKmWC5B BN7dazzTLzr9QAHWn1dnNXWbt7UVn2AHz5dWAxOYYGTCKlduCqaJU8d1Bo4O0+E6Qxqi XCUF+KEaxc9aXz1p7ojum3VRzHWQ9HnnvvB/kPNwLjHv8aAfmmj3Ype0z3m4Xq0t5O/v xYIiezS6p+nZv9uoPmvZ2PEqO4mzf0IrS4ZyypAOxjesKByEf5gERE0CN9ZXtH/pl77E AWPi7MC7X9lqdhc0yYZmFOKB9B8XRrKza4OtvRde7vDEx+3Xz5/HTfnKsQhhSBYpO6HH xmOw== X-Gm-Message-State: AOAM533noagF1t+Bzp2tylAWiWh9W5AVnXM+Fc+xSleCRkDkFJ7ScDhz YgE16yPNE1XrBsnePpe9On1tCXJ7tppE2Q== X-Google-Smtp-Source: ABdhPJytuoU6qMoZ2W/ank348seBjVz4gSwu/2af6weTzTnKvrgRzgj8otRnW5+PChDPa4qyOWWoIQ== X-Received: by 2002:a9d:3a6:: with SMTP id f35mr7880996otf.144.1629344784919; Wed, 18 Aug 2021 20:46:24 -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 q3sm370025ooa.13.2021.08.18.20.46.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 20:46:24 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Steffen Jaeckel , Michal Simek , Tom Rini , Dennis Gilmore , Daniel Schwierzeck , Lukas Auer , Simon Glass Subject: [PATCH 12/28] pxe: Drop get_bootfile_path() Date: Wed, 18 Aug 2021 21:45:45 -0600 Message-Id: <20210818214547.12.Iabd27f61cd3bf528f835dea68f0c3997e85be0d0@changeid> X-Mailer: git-send-email 2.33.0.rc1.237.g0d66db33f3-goog In-Reply-To: <20210819034601.1618773-1-sjg@chromium.org> References: <20210819034601.1618773-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 --- 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.rc1.237.g0d66db33f3-goog