Received: from mailman by lists.gnu.org with archive (Exim 4.33) id 1BbQv8-0002Dm-O7 for mharc-grub-devel@gnu.org; Fri, 18 Jun 2004 17:29:10 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BbQv8-0002Dh-56 for grub-devel@gnu.org; Fri, 18 Jun 2004 17:29:10 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BbQv7-0002DV-Cl for grub-devel@gnu.org; Fri, 18 Jun 2004 17:29:09 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BbQv7-0002DS-A7 for grub-devel@gnu.org; Fri, 18 Jun 2004 17:29:09 -0400 Received: from [195.113.31.125] (helo=artax.karlin.mff.cuni.cz) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BbQts-0006yJ-AK for grub-devel@gnu.org; Fri, 18 Jun 2004 17:27:52 -0400 Received: by artax.karlin.mff.cuni.cz (Postfix, from userid 17122) id 4399C423D; Fri, 18 Jun 2004 23:27:51 +0200 (CEST) Date: Fri, 18 Jun 2004 23:27:51 +0200 To: The development of GRUB 2 Message-ID: <20040618212751.GA11637@artax.karlin.mff.cuni.cz> Mail-Followup-To: The development of GRUB 2 References: <20040615113103.GA4639@artax.karlin.mff.cuni.cz> <20040615113923.GA5398@artax.karlin.mff.cuni.cz> <20040615134517.GA19541@artax.karlin.mff.cuni.cz> <87r7sgvrd1.fsf@marco.marco-g.com> <20040615162213.GA1760@artax.karlin.mff.cuni.cz> <20040615180341.GA11591@artax.karlin.mff.cuni.cz> <87brjkh82n.fsf@marco.marco-g.com> <20040616084802.GA18807@artax.karlin.mff.cuni.cz> <877ju4bn8y.fsf@marco.marco-g.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <877ju4bn8y.fsf@marco.marco-g.com> User-Agent: Mutt/1.5.6i From: ebik@artax.karlin.mff.cuni.cz (Tomas Ebenlendr) Subject: Re: normal/cmdline bug & patch X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jun 2004 21:29:10 -0000 > > Can you send the patch in an attachment? (and preferable -up diffed) > I did diff once more and compared the two diffs. They differed in some whitespaces. I probably deleted them when viewing the patch with vim. (I store my grub2 patches, because I want to be able reconstruct sources when I mess them up by my debuging prints.) Here is the correct patch: Changelog (probably too much detail): Bugfix of grub_set_history. * normal/cmdline.c(grub_set_history): fix1(55): hist_end points to first _empty_ entry fix2(58,2): pos cannot overflow, but can underflow fix3(65): correction must act as modulo fix4(71)[hist_pos==hist_end]: copy nothing if hist_used == 0 fix5(73,9): buffer was copied wrong way --- grub2_nonpatched/normal/cmdline.c 2004-06-18 23:05:53.000000000 +0200 +++ grub2_patched/normal/cmdline.c 2004-06-15 19:55:45.000000000 +0200 @@ -52,33 +52,35 @@ grub_set_history (int newsize) int delsize = hist_used - newsize; hist_used = newsize; - for (i = 0; i < delsize; i++) + for (i = 1; i <= delsize; i++) { int pos = hist_end - i; - if (pos > hist_size) - pos -= hist_size; + if (pos < 0) + pos += hist_size; grub_free (old_hist_lines[pos]); } hist_end -= delsize; if (hist_end < 0) - hist_end = hist_size - hist_end; + hist_end += hist_size; } if (hist_pos < hist_end) grub_memmove (hist_lines, old_hist_lines + hist_pos, (hist_end - hist_pos) * sizeof (char *)); - else + else if (hist_used) { - /* Copy the first part. */ - grub_memmove (hist_lines, old_hist_lines, - hist_pos * sizeof (char *)); - + /* old_hist_lines: 0 hist_end hist_pos */ + /* entry at hist_end is empty, at hist_pos contains first entry */ - /* Copy the last part. */ - grub_memmove (hist_lines + hist_pos, old_hist_lines + hist_pos, + /* Copy the older part. */ + grub_memmove (hist_lines, old_hist_lines + hist_pos, (hist_size - hist_pos) * sizeof (char *)); + /* Copy the newer part. */ + grub_memmove (hist_lines + hist_size - hist_pos, old_hist_lines, + hist_end * sizeof (char *)); + } } -- Tomas 'ebi' Ebenlendr http://get.to/ebik PF 2004.46438850309