From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1N7bZK-0002WS-Kx for mharc-grub-devel@gnu.org; Mon, 09 Nov 2009 16:14:34 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N7bZJ-0002Uu-0u for grub-devel@gnu.org; Mon, 09 Nov 2009 16:14:33 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N7bZD-0002QR-E3 for grub-devel@gnu.org; Mon, 09 Nov 2009 16:14:31 -0500 Received: from [199.232.76.173] (port=32863 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N7bZD-0002QL-4h for grub-devel@gnu.org; Mon, 09 Nov 2009 16:14:27 -0500 Received: from esemetz.metz.supelec.fr ([193.48.224.212]:60695) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N7bZC-0007GN-MU for grub-devel@gnu.org; Mon, 09 Nov 2009 16:14:27 -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 nA9LEO1s007081 for ; Mon, 9 Nov 2009 22:14:24 +0100 Received: from [127.0.0.1] (Java_cJ@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 nA9LEJtM026857 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Mon, 9 Nov 2009 22:14:19 +0100 Message-ID: <4AF885EE.7000709@duboucher.eu> Date: Mon, 09 Nov 2009 22:13:18 +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> In-Reply-To: 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:14:24 +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:14:24 +0100 (CET) Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by esemetz.metz.supelec.fr id nA9LEO1s007081 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:14:33 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Bean a =E9crit : >=20 > Hi, >=20 > This one work: >=20 > int > auth_strcmp (const char *s1, const char *s2) > { > int result =3D 0; >=20 > while (1) > { > result +=3D (*s1 !=3D *s2); > if (*s1 =3D=3D 0) > break; >=20 > s1++; > s2++; > } >=20 > return (result !=3D 0); > } >=20 > The trick is to compare the ending '\0' as well, so that partial match > is not satisfied. >=20 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 nicer in terms of pure logic. "The comparison beetwen s1 and s2 is false if *s1 is different from *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; } Also, because s1 and s2 have two differents roles, I think it would be best to give them names that better suits them. ;) Thomas. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkr4he4ACgkQBV7eXqefhqj0kACgkgE60xJe5X/zpmXoPEd9SsT9 6H8An113fF03h0cndz2LpJvqnPyJ3EPx =3D5MEi -----END PGP SIGNATURE-----