Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1n7qH4-0004Kx-7K for mharc-grub-devel@gnu.org; Wed, 12 Jan 2022 21:55:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7qGw-0004Dy-GS for grub-devel@gnu.org; Wed, 12 Jan 2022 21:55:30 -0500 Received: from [2607:f8b0:4864:20::82b] (port=35492 helo=mail-qt1-x82b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n7qGm-00013G-Pg for grub-devel@gnu.org; Wed, 12 Jan 2022 21:55:26 -0500 Received: by mail-qt1-x82b.google.com with SMTP id c10so5513344qte.2 for ; Wed, 12 Jan 2022 18:55:18 -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=XwaJwnZFYf64dwrfl8XbI5swqHd5kriv+fi0XX0VwwU=; b=S0hpJrkjySHZRRaIouEO0bESzx/xU050OiuKerxwGaBd2QDamqWi5Espd0rRP8W6+z rUJTsA3FXKV3exWRHkEUI2vowjHaVKiDMcsy/fQuW7/Fy/K9SvtTDjCgWsD9ry2miV9d 0xtl9V9tR0agQWAndC9yJWtY7Iykk+uEujJcy2a8B3+IggTWCWtmSrWaVfKSqKXMIZy0 82c9MPC/PS0myzPbeiSd/tF8RAxA4JGawCpVHCB0BYVYUxz6FGcbqGGY9/+ZObIAZbfW 4HaJsr+X8zQoEIi3o70y2NH7SG4Q1oLJmls0slVSoyiBMz1kZlVOuxxcEbcAJtJsB1Cy Tczg== 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=XwaJwnZFYf64dwrfl8XbI5swqHd5kriv+fi0XX0VwwU=; b=1fpKKhPAnocdRud9mlQzUutAwo8CUsBrpQcVrmMODYsBtZdox5hV4Z3HYJ5N3vu3IB 5+yZDYTVTXwUXYuolLnYFUlzVT/wUYKCs/e9QnIJJAPtNWsX7fBfxz/yogLbQS9vqTcy frZySNiwhIh+lFyQv/aBgWK78wEtRvxct6S9J1vtMXcQtW0AftQTM5okIf4CNZAxmHjC 4X6tC88T7/l/cJOco8EUCEdkWFaQPyp+k/ds4OKH1IMXBFapLsf2nXVD4pbo2YN+R5nV C/EbPshfK69VpeqmFTFwSwQUmhHfmG1rBXi4+oFI06Wd6m3vqHDqTfowVOujvuhaxq6z s0Yw== X-Gm-Message-State: AOAM533zTtvcc58Yn1pYDfumD44P2ilSLj9whXUWcBnPMl3ITSCh2WuJ qPPOgRXgST2s9o8nytTHv8ZG/KKHDcDCTg== X-Google-Smtp-Source: ABdhPJx1d+SPQjvHw1d/3N1cYg9GyFe1v/Qa5ITLuxP/6GnAl86KsyT448cthGaA0xflQl7CuUXQNw== X-Received: by 2002:ac8:7d86:: with SMTP id c6mr2125002qtd.250.1642042517633; Wed, 12 Jan 2022 18:55:17 -0800 (PST) Received: from localhost.localdomain ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id m13sm976151qkk.122.2022.01.12.18.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 18:55:17 -0800 (PST) From: Glenn Washburn To: Daniel Kiper , grub-devel@gnu.org Cc: Glenn Washburn Subject: [PATCH 2/2] util/resolve.c: Bail with error if moddep lst file line is too long Date: Wed, 12 Jan 2022 20:55:01 -0600 Message-Id: <30047216142226c72743c129206ba0594789e7fe.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::82b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::82b; envelope-from=development@efficientek.com; helo=mail-qt1-x82b.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 The code reads each line into a buffer of size 1024 and does not check if the line is longer. So a line longer than 1024 will be read as a valid line followed by an invalid line. Then an error confusing to the user is sent with the test "invalid line format". But the line format is prefectly fine, the problem is in GRUB's parser. Check if we've hit a line longer than the size of the buffer, and if so send a more correct and reasonable error. Signed-off-by: Glenn Washburn --- util/resolve.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/resolve.c b/util/resolve.c index 5e9afa10c..b0f2661f7 100644 --- a/util/resolve.c +++ b/util/resolve.c @@ -127,6 +127,9 @@ read_dep_list (FILE *fp) mod->next = dep->list; dep->list = mod; } + + if ((p - buf) == sizeof (buf)) + grub_util_error (_("line too long, length greater than %lu: module %s"), sizeof (buf), dep->name); } return dep_list; -- 2.27.0