[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] for some of issue #649

From: Branko Čibej <brane_at_xbc.nu>
Date: 2003-01-07 00:30:27 CET

Karl Fogel wrote:

>Issue #649 is the harder half of issue #689; together, they're my
>front burner right now. I'm posting this patch for review because I
>haven't been in the filesystem code for a while -- am especially
>hoping cmpilato will have time to review it :-), but any eyeballs are
>welcome.
>
>It passes 'make check' except for 'strings-reps-test 3', which I'm
>currently tweaking. I'm more looking for comments about the general
>shape of the checksum code.
>
[snip]

>+/* Compare digests D1 and D2, each MD5_DIGESTSIZE bytes long. If
>+ * neither is all zeros, and they do not match, then return false.
>+ * Else return true.
>+ */
>+static svn_boolean_t
>+checksums_match (unsigned const char d1[], unsigned const char d2[])
>+{
>+ auto unsigned char zeros[MD5_DIGESTSIZE] = { 0 };
>+
>+ if ((strncmp (d1, zeros, MD5_DIGESTSIZE) == 0)
>+ || (strncmp (d2, zeros, MD5_DIGESTSIZE) == 0))
>+ return TRUE;
>+ else
>+ return (strncmp (d1, d2, MD5_DIGESTSIZE) == 0);
>+}
>
What on earth are you doing, using strncmp to compare arrays that can
contain nul bytes? Try memcmp, then this function might actually work
correctly. Not that this has anything to do with FS code. :-)

-- 
Brane Čibej   <brane_at_xbc.nu>   http://www.xbc.nu/brane/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Jan 7 00:33:28 2003

This is an archived mail posted to the Subversion Dev mailing list.