Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1p8XC9-0004eh-0l for mharc-grub-devel@gnu.org; Thu, 22 Dec 2022 20:49:57 -0500 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 1p8XC7-0004bQ-Qt for grub-devel@gnu.org; Thu, 22 Dec 2022 20:49:55 -0500 Received: from gate.crashing.org ([63.228.1.57]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p8XC6-0002Kq-Cc for grub-devel@gnu.org; Thu, 22 Dec 2022 20:49:55 -0500 Received: from u0f3226c756e75a.ant.amazon.com (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 2BN1moCp029793; Thu, 22 Dec 2022 19:48:52 -0600 From: Benjamin Herrenschmidt To: grub-devel@gnu.org Cc: Daniel Kiper Subject: [PATCH 1/3] serial: Replace usage of memcmp with strncmp Date: Fri, 23 Dec 2022 12:48:47 +1100 Message-Id: <20221223014849.2112927-2-benh@kernel.crashing.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221223014849.2112927-1-benh@kernel.crashing.org> References: <20221223014849.2112927-1-benh@kernel.crashing.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=63.228.1.57; envelope-from=benh@kernel.crashing.org; helo=gate.crashing.org 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 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: Fri, 23 Dec 2022 01:49:56 -0000 We are comparing strings after all Signed-off-by: Benjamin Herrenschmidt --- grub-core/term/serial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/term/serial.c b/grub-core/term/serial.c index d161e1d36..88bcd4032 100644 --- a/grub-core/term/serial.c +++ b/grub-core/term/serial.c @@ -152,7 +152,7 @@ grub_serial_find (const char *name) break; #if (defined(__mips__) || defined (__i386__) || defined (__x86_64__)) && !defined(GRUB_MACHINE_EMU) && !defined(GRUB_MACHINE_ARC) - if (!port && grub_memcmp (name, "port", sizeof ("port") - 1) == 0 + if (!port && grub_strncmp (name, "port", sizeof ("port") - 1) == 0 && grub_isxdigit (name [sizeof ("port") - 1])) { name = grub_serial_ns8250_add_port (grub_strtoul (&name[sizeof ("port") - 1], @@ -242,7 +242,7 @@ grub_serial_find (const char *name) #endif #ifdef GRUB_MACHINE_IEEE1275 - if (!port && grub_memcmp (name, "ieee1275/", sizeof ("ieee1275/") - 1) == 0) + if (!port && grub_strncmp (name, "ieee1275/", sizeof ("ieee1275/") - 1) == 0) { name = grub_ofserial_add_port (&name[sizeof ("ieee1275/") - 1]); if (!name) -- 2.34.1