Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1n7qGz-0004GZ-PS for mharc-grub-devel@gnu.org; Wed, 12 Jan 2022 21:55:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7qGu-0004DZ-Qs for grub-devel@gnu.org; Wed, 12 Jan 2022 21:55:30 -0500 Received: from [2607:f8b0:4864:20::834] (port=45570 helo=mail-qt1-x834.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n7qGk-00012Z-Rd for grub-devel@gnu.org; Wed, 12 Jan 2022 21:55:22 -0500 Received: by mail-qt1-x834.google.com with SMTP id b14so2557703qtb.12 for ; Wed, 12 Jan 2022 18:55:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tb+u6XaDwoTxxnhbsySvc3Z6ACaqw20OCHLMBHH1KPM=; b=zfOhHWZOj+uOS1F1WpABHmbstrdcoLTKSoJaAXzawdwbjzmLB7x3kMmpvIPZ/o1rLL gMNs+F632p8SahvhFHXli1F2U1AzFY8eCPjuoHx1HaTsUjyXBtnoSmxor4Qx9VFHkMGe qn9oY1X9PlftcFNJL+cX3USfSikbGQsmPbKyqlkhyXx/WPy30Is34Y3sU1PRbVZnkJ/Q PdXjQ6uT1UPclpMteUFMqWXkql4zWtHXuaqMEamyziF2TWIa12X59QHujs5wfYyJG3d1 dOCqrNQgRQvTdftQMNAGtC6vsbVIgGzzoTPUIsD7M0vqqxbA8zEE/QTayiYKXQ2ZugjW bYyA== 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=tb+u6XaDwoTxxnhbsySvc3Z6ACaqw20OCHLMBHH1KPM=; b=W7I+pWTSW/F/CqZQfnaUUXDocaYfCcxdrR0JAxdeOPbu2tCWhAtcN9j2kXQDX4hTQP kyrNtcGZkvwfO3pY6ikpH5JaRj6Qznwol4Igcxx6gmqOeWfTAkAxNCEOeC+f3HQQgiib CH7jc5nUcg2fujfNP27gqe0VQ21yhB0Cx8WaSDE6GHxw8hDm3m+4FGShKHgZhUp3ispe vTizFiDmGZ0Koo+CiJVSDqyRgpUAzAtF1bGSxh9BA69qrOMgnd0aenqLnLPVSzedrg0C /D2V9m7L9G55gLNHdJ8Tk0Ja0zx1rMWlAwDvaUceWEQYKbnjJyt0vxA0CYwe49rpAXLL UYzw== X-Gm-Message-State: AOAM5337Cul+Cf5gy6oeuS08DQZbgRa9MK7vmKcgLn0VtqJ4OIYORRGz tig97czf2c+aj8qAGrLqPg75UQ== X-Google-Smtp-Source: ABdhPJz4MdN1k6bigB3IhNPc09Fx1hxVJBUoIOxV2ROmxJp52umpJ38jFonEaecPsLLGiafmZv76dQ== X-Received: by 2002:ac8:5bce:: with SMTP id b14mr2126563qtb.614.1642042516007; Wed, 12 Jan 2022 18:55:16 -0800 (PST) Received: from localhost.localdomain ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id m13sm976151qkk.122.2022.01.12.18.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 18:55:15 -0800 (PST) From: Glenn Washburn To: Daniel Kiper , grub-devel@gnu.org Cc: Glenn Washburn Subject: [PATCH 1/2] util/resolve.c: Do not read past the end of the array in read_dep_list Date: Wed, 12 Jan 2022 20:55:00 -0600 Message-Id: <5836fd304c3e757239d1830274b142cc2f97c89b.1642042033.git.development@efficientek.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::834 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::834; envelope-from=development@efficientek.com; helo=mail-qt1-x834.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Thu, 13 Jan 2022 02:55:30 -0000 If the last non-NULL byte of 'buf' is not a white-space character (such as when a read line is longer than the size of 'buf'), then 'p' will eventually point to the byte after the last byte in 'buf'. After which 'p' will be dereferenced in the while conditional leading to an out of bounds read. Make sure that 'p' is inside 'buf' before dereferencing it. Signed-off-by: Glenn Washburn --- util/resolve.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/resolve.c b/util/resolve.c index 3e887d2ff..5e9afa10c 100644 --- a/util/resolve.c +++ b/util/resolve.c @@ -102,7 +102,7 @@ read_dep_list (FILE *fp) dep_list = dep; /* Add dependencies. */ - while (*p) + while (p < (buf + sizeof (buf)) && *p) { struct mod_list *mod; char *name; -- 2.27.0