From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1N7mN4-0004ka-Un for mharc-grub-devel@gnu.org; Tue, 10 Nov 2009 03:46:38 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N7mN3-0004kO-FT for grub-devel@gnu.org; Tue, 10 Nov 2009 03:46:37 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N7mMy-0004jo-WF for grub-devel@gnu.org; Tue, 10 Nov 2009 03:46:36 -0500 Received: from [199.232.76.173] (port=46369 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N7mMy-0004jl-QD for grub-devel@gnu.org; Tue, 10 Nov 2009 03:46:32 -0500 Received: from mail-px0-f191.google.com ([209.85.216.191]:34560) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N7mMy-00045e-BU for grub-devel@gnu.org; Tue, 10 Nov 2009 03:46:32 -0500 Received: by pxi29 with SMTP id 29so499163pxi.1 for ; Tue, 10 Nov 2009 00:46:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=bna6vsEHBZUZN0l8L14ZPSmwQc7HKsEaMbSUTOdIi90=; b=ueQAE/kdmUmjTqm1IireECFAYz61q7Nt6RNipSAXRtK7dgvj5LqsKFR8loRNlBPzc3 OOhOoJsVdyS6RdHLkqzJYDycrehAvo/E3C2Oh5/22mU7be1MGc/rjKe6peUqMsHAim1L sGFCG9nmSLlNKieuuWySICbv0i0iKOE4vJ8q0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=al7rgyzZWs/KcHE7tSXrFpvwE36e0bzqv/tMs1oQF6sHyzn1Oj4WGoLG3asbpfGem5 8cIDlECh7I7U1AEDHcgVZl1KTNT0sGISf0BvSif0Waki9ygXz+PQQWMyayGY58zbS5j6 1qzIF/jSBYW7j4dZVAWh081MJM86Zs5fQ4AcE= MIME-Version: 1.0 Received: by 10.141.13.13 with SMTP id q13mr486402rvi.40.1257842791489; Tue, 10 Nov 2009 00:46:31 -0800 (PST) In-Reply-To: References: <20091109010422.GA23417@thorin> <4AF85C54.3080302@gmail.com> <20091109182518.GA14767@thorin> <4AF86387.7090307@gmail.com> <4AF885EE.7000709@duboucher.eu> <4AF88AEF.8010102@gmail.com> Date: Tue, 10 Nov 2009 16:46:31 +0800 Message-ID: From: Bean To: The development of GNU GRUB Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: Imminent bugfix release (1.97.1) X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 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: Tue, 10 Nov 2009 08:46:37 -0000 On Tue, Nov 10, 2009 at 4:28 PM, Bean wrote: > On Tue, Nov 10, 2009 at 1:39 PM, Bean wrote: >> On Tue, Nov 10, 2009 at 5:34 AM, Vladimir 'phcoder' Serbinenko >> wrote: >>> But now it has a technical problem: it may read post array definitions. >>> If any of post-array memory is MMIO or absent reading from it may have >>> peculiar consequences >>>> =A0 =A0 Also, because s1 and s2 have two differents roles, I think it = would be >>>> best to give them names that better suits them. ;) >> >> Hi, >> >> Right, I think it'd be better to use fixed size array, perhaps we can >> define a type grub_password_t for it. >> >> BTW, with fixed size array, the following algorithm should run exactly >> the same amount of instruction each time: >> >> typedef char grub_password_t[1024]; >> >> int >> grub_auth_strcmp (const grub_password_t s1, const grub_password_t s2) >> { >> =A0int r1 =3D 0; >> =A0int r2 =3D 0; >> =A0int i, *p; >> >> =A0p =3D &r1; >> =A0for (i =3D 0; i < sizeof (grub_password_t); i++, s1++, s2++) >> =A0 =A0{ >> =A0 =A0 =A0*p |=3D (*s1 ^ *s2); >> =A0 =A0 =A0if (*s1 =3D=3D '\0') >> =A0 =A0 =A0 =A0p =3D &r2; >> =A0 =A0} >> >> =A0return (r1 !=3D 0); >> } > > Hi, > > Oh sorry, this one still have some issue, this should work: > > typedef char grub_password_t[1024]; > > int > grub_auth_strcmp (const grub_password_t s1, const grub_password_t s2) > { > =A0int r1 =3D 0; > =A0int r2 =3D 0; > =A0int i, *p1, *p2; > > =A0p1 =3D p2 =3D &r1; > =A0for (i =3D 0; i < sizeof (grub_password_t); i++, s1++, s2++) > =A0 =A0{ > =A0 =A0 =A0*p1 |=3D (*s1 ^ *s2); > =A0 =A0 =A0if (*s1 =3D=3D '\0') > =A0 =A0 =A0 =A0p1 =3D &r2; > =A0 =A0 =A0else > =A0 =A0 =A0 =A0p2 =3D &r2; > =A0 =A0} > > =A0return (r1 !=3D 0); > } Hi, Just in case p2 is optimized out by gcc: typedef char grub_password_t[1024]; int grub_auth_strcmp (const grub_password_t s1, const grub_password_t s2) { char r1 =3D 0; char r2 =3D 0; char r3 =3D 0; char *p1, *p2; int i; p1 =3D &r1; p2 =3D &r3; for (i =3D 0; i < sizeof (grub_password_t); i++, s1++, s2++) { *p1 |=3D (*s1 ^ *s2); if (*s1 =3D=3D '\0') p1 =3D &r2; else p2 =3D &r2; (*p2)++; } return (r1 !=3D 0); } --=20 Bean My repository: https://launchpad.net/burg Document: https://help.ubuntu.com/community/Burg