From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1N7c2u-0002mr-LQ for mharc-grub-devel@gnu.org; Mon, 09 Nov 2009 16:45:08 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N7c2t-0002kw-Cp for grub-devel@gnu.org; Mon, 09 Nov 2009 16:45:07 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N7c2o-0002dC-LO for grub-devel@gnu.org; Mon, 09 Nov 2009 16:45:06 -0500 Received: from [199.232.76.173] (port=38356 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N7c2o-0002cy-5x for grub-devel@gnu.org; Mon, 09 Nov 2009 16:45:02 -0500 Received: from esemetz.metz.supelec.fr ([193.48.224.212]:40227) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N7c2n-0003mn-Ja for grub-devel@gnu.org; Mon, 09 Nov 2009 16:45:01 -0500 Received: from mx1.metz.supelec.fr (mx1.metz.supelec.fr [193.48.224.216]) by esemetz.metz.supelec.fr (8.14.1/8.14.1) with ESMTP id nA9Lixli007432 for ; Mon, 9 Nov 2009 22:44:59 +0100 Received: from [127.0.0.1] (duboucher.rez-metz.supelec.fr [193.48.225.222] (may be forged)) by mx1.metz.supelec.fr (8.14.1/8.14.1) with ESMTP id nA9Lisj6029352 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Mon, 9 Nov 2009 22:44:54 +0100 Message-ID: <4AF88D14.2030108@duboucher.eu> Date: Mon, 09 Nov 2009 22:43:48 +0100 From: Duboucher Thomas User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: The development of GNU GRUB References: <20091109010422.GA23417@thorin> <4AF81E2C.2090700@gmail.com> <4AF82868.6090803@gmail.com> <4AF85568.7080105@duboucher.eu> <20091109181010.GA7372@thorin> <4AF85C54.3080302@gmail.com> <20091109182518.GA14767@thorin> <4AF86387.7090307@gmail.com> <4AF885EE.7000709@duboucher.eu> <4AF88AEF.8010102@gmail.com> In-Reply-To: <4AF88AEF.8010102@gmail.com> X-Enigmail-Version: 0.96.0 OpenPGP: id=A79F86A8 Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: ClamAV 0.94.1/9999/Sat Nov 7 09:23:30 2009 on mx1.metz.supelec.fr X-Virus-Status: Clean X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (esemetz.metz.supelec.fr [193.48.224.212]); Mon, 09 Nov 2009 22:44:59 +0100 (CET) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (mx1.metz.supelec.fr [193.48.224.216]); Mon, 09 Nov 2009 22:44:59 +0100 (CET) Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by esemetz.metz.supelec.fr id nA9Lixli007432 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) 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: Mon, 09 Nov 2009 21:45:07 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Vladimir 'phcoder' Serbinenko a =E9crit : > Duboucher Thomas wrote: >> Bean a =E9crit : >>> Hi, >>> This one work: >>> int >>> auth_strcmp (const char *s1, const char *s2) >>> { >>> int result =3D 0; >>> while (1) >>> { >>> result +=3D (*s1 !=3D *s2); >>> if (*s1 =3D=3D 0) >>> break; >>> s1++; >>> s2++; >>> } >>> return (result !=3D 0); >>> } >>> The trick is to compare the ending '\0' as well, so that partial matc= h >>> is not satisfied. >> >> Yep, I like this one, but I would prefer using an OR instead of an= ADD >> (with a highly hypothetical integer overflow :p) and because it's nice= r >> in terms of pure logic. >> "The comparison beetwen s1 and s2 is false if *s1 is different fro= m >> *s2, or recursively if the comparison beetwen s1+1 and s2+1 is false" >> >> int >> auth_strcmp (const char *s1, const char *s2) >> { >> int ret =3D 0; >> >> for (;;) >> { >> ret |=3D (*s1 !=3D *s2); >> >> if (*s1 =3D=3D '\0') >> break; >> >> s1++; >> s2++; >> } >> >> return ret; >> } >> > 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 Well, the only way to solve that problem would be IMHO to add a limit to the size of s2, and use this maximum size as an end condition for the 'for' statement. Any better idea? :) int auth_strcmp (const char *s1, const char *s2) { int ret, n; for (ret =3D n =3D 0; ret < PASSPHRASE_MAXSIZE; ret++) { ret |=3D (*s1 !=3D *s2); if (*s1 =3D=3D '\0') break; s1++; s2++; } return ret; } >> Also, because s1 and s2 have two differents roles, I think it woul= d be >> best to give them names that better suits them. ;) >> >> Thomas. >=20 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkr4jRQACgkQBV7eXqefhqhJ3gCeNLHYAeVSb0qQ4GLgxbVvlDV7 P3oAoIvTa2Y+6i6BY1vTaOXXMklLVN8p =3D7x71 -----END PGP SIGNATURE-----