From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1qEPYz-0006SM-U4 for mharc-grub-devel@gnu.org; Wed, 28 Jun 2023 03:26:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qEPYv-0006QQ-9d for grub-devel@gnu.org; Wed, 28 Jun 2023 03:26:01 -0400 Received: from mail-vk1-xa31.google.com ([2607:f8b0:4864:20::a31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qEPYr-0004os-PS for grub-devel@gnu.org; Wed, 28 Jun 2023 03:26:01 -0400 Received: by mail-vk1-xa31.google.com with SMTP id 71dfb90a1353d-47169fc1a40so1961705e0c.0 for ; Wed, 28 Jun 2023 00:25:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20221208.gappssmtp.com; s=20221208; t=1687937135; x=1690529135; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=7tnLCNalNTNTkJWnAiHAzLxBKMnoz0hZ6fVAdAZ3D70=; b=EPxM79qjfhOD01A3bkHvQ/YVecLMG11pZztmIZOc1WzQI4tyWlk5dRwttTnF9a3Mb4 30UrUuV6K9bQq+kfIV0tmAbFyKxbmJCZ39i9iw5Y/tH/LiIBjr6N+/MFNpytWq3KS3Yx nParJeLMr4CWdEPVweDhep5EPKlfkS6AXYKD5sUvb5FwVw/g3lGp3yonyBT2dCWlL/3v 6acqps3owTwYBtxt+eAZnuLcDUHgZlCuZ/oC4+Ffa7UCGCPL8F89zGu4uIDpm35hrOhF cwJFNOYVYkAYOlnDjuJcCi+H5PKPhB79++PeBlViyABqIy0VltMiWeagNhN4QLfKFoTe z6Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687937135; x=1690529135; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7tnLCNalNTNTkJWnAiHAzLxBKMnoz0hZ6fVAdAZ3D70=; b=BIm7Z5QXSG1ThXBqPvXUnqQrTB0QE7S3ikRdQjMDvuL+iRoMY04Jw07QA1OtcPpZpU mQ6HCSQAGZR7WeM1SCs1bxvTp8/ZpD41A5nfnGixlGLlzA9Vi6FakzM+574F+Fu8I05N DjFWcC1q7HNWBvyeT8oeoFbkGHlRfbuVUsjQFVpDSixLoXiNZI/ZhWKjG55WU4e5bf+f 1bBC5Pdw8uEO6dhPdk1VaT6n0cn9HG6T8wChI7eJjfA1m4HNy8gNGx9w9y+XGuG/IwAF d/WBd5HPlR+BO1otYbUuhreeAamrSmUEaHyR8QXRK6t09qNrLrgzwP9tF9H4EJk4lvsl nrOA== X-Gm-Message-State: AC+VfDwhXIfcvopIiChpnEt8uqTK48l50SA/JjO54yeoTH41q9kQCtH7 nI1M9lK1dmZHU8ylAFMGo36dyVwA1YNEWKOHNIQPOQ== X-Google-Smtp-Source: ACHHUZ4WbqPAkISxEdZsc3/vnb+uFGrxX2CGvIMrWypTeLhyXpoVxhY+ht7Vrs1ahBgm+Je1GVQL0Q== X-Received: by 2002:a1f:5ec4:0:b0:471:8ca7:88b4 with SMTP id s187-20020a1f5ec4000000b004718ca788b4mr15191048vkb.9.1687937134777; Wed, 28 Jun 2023 00:25:34 -0700 (PDT) Received: from localhost.localdomain ([37.218.244.249]) by smtp.gmail.com with ESMTPSA id e8-20020a1f1e08000000b0045a2a4c9cb9sm1868582vke.34.2023.06.28.00.25.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 00:25:33 -0700 (PDT) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Glenn Washburn Subject: [PATCH] loader/linux: Only emit newc directory once Date: Wed, 28 Jun 2023 02:25:16 -0500 Message-Id: <20230628072516.481118-1-development@efficientek.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::a31; envelope-from=development@efficientek.com; helo=mail-vk1-xa31.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Jun 2023 07:26:01 -0000 When creating at runtime a newc initrd via arguments to initrd with "newc:" prefixes, only emit a directory path record once. The original code intended to do that by bailing out of emiting the record when the record to be created matches an existing record. However, this does not happen because grub_memcmp() is improperly checked. Generating duplicate newc directory records does not cause any problems because the linux unpacker will skip it once it sees the directory already exists. This fix saves a little processing and makes the generated newc cpio archive a little smaller. Fixes: 92750e4c60 (Add ability to generate newc additions on runtime.) Signed-off-by: Glenn Washburn --- grub-core/loader/linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c index 3948302d2c43..cb2c3f6e4f06 100644 --- a/grub-core/loader/linux.c +++ b/grub-core/loader/linux.c @@ -114,7 +114,7 @@ insert_dir (const char *name, struct dir **root, break; for (cur = *root; cur; cur = cur->next) - if (grub_memcmp (cur->name, cb, ce - cb) + if (grub_memcmp (cur->name, cb, ce - cb) == 0 && cur->name[ce - cb] == 0) break; if (!cur) -- 2.34.1