Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Sa4Lw-0006hD-Nw for mharc-grub-devel@gnu.org; Thu, 31 May 2012 08:19:44 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sa4Lq-0006gY-3y for grub-devel@gnu.org; Thu, 31 May 2012 08:19:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sa4Lk-0004bp-PG for grub-devel@gnu.org; Thu, 31 May 2012 08:19:37 -0400 Received: from 37-46-169-123.customers.ownit.se ([37.46.169.123]:59524 helo=zoo.weinigel.se) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sa4Lk-0004bV-IX for grub-devel@gnu.org; Thu, 31 May 2012 08:19:32 -0400 Received: by zoo.weinigel.se (Postfix, from userid 500) id 5438760D07; Thu, 31 May 2012 13:43:29 +0200 (CEST) From: Christer Weinigel To: grub-devel@gnu.org Subject: [PATCH] fix off-by-one in grub_file_getline Message-Id: <20120531114329.5438760D07@zoo.weinigel.se> Date: Thu, 31 May 2012 13:43:29 +0200 (CEST) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 37.46.169.123 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 May 2012 12:19:44 -0000 I'd like to submit a few trivial patches that I've had on my hard drive for a while. This patch is against the latest version in the trunk on bzr.savannah.gnu.org. If grub_file_getline tries to read a line which is exactly 64 bytes long it will write the terminating zero past the end of the allocated buffer causing memory corruption. Trivial fix which reserves one more byte in the buffer. diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c index feeb1ef..eb4b1c7 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -65,7 +65,7 @@ grub_file_getline (grub_file_t file) continue; - if (pos >= max_len) + if (pos + 1 >= max_len) { char *old_cmdline = cmdline; max_len = max_len * 2; -- Have laptop, will travel. I'm a consultant looking for interesting jobs anywhere in the world. I'm an experienced software engineer with a solid understanding of hardware. Specialities: Linux, device drivers and embedded systems in general. Find me at www.weinigel.se.