standards/55370: [patch] uuid_compare function (uuid(3)) incorrectly compares node fields.

Oznobihin Konstantin bork at asterix.rsu.ru
Fri Aug 8 05:50:25 PDT 2003


The following reply was made to PR standards/55370; it has been noted by GNATS.

From: Oznobihin Konstantin <bork at asterix.rsu.ru>
To: FreeBSD-gnats-submit at FreeBSD.org
Cc:  
Subject: Re: standards/55370: [patch] uuid_compare function (uuid(3))
	incorrectly compares node fields.
Date: 08 Aug 2003 12:41:54 +0000

 >return (memcmp(a->node, b->node, _UUID_NODE_LEN));
 Sorry, this patch isn't sufficient, because memcmp returns the
 difference between the first two differing bytes. Here is complete
 patch:
 --- uuid_compare.patch_2 begins here ---
 --- uuid_compare.c      Fri Aug  8 16:18:26 2003
 +++ /usr/src/lib/libc/uuid/uuid_compare.c       Wed Oct 30 06:51:00 2002
 @@ -72,8 +72,5 @@
         res = (int)a->clock_seq_low - (int)b->clock_seq_low;
         if (res)
                 return ((res < 0) ? -1 : 1);
 -       res = memcmp(a->node, b->node, _UUID_NODE_LEN);
 -       if (res)
 -               return ((res < 0) ? -1 : 1);
 -       return res;
 +       return (memcmp(a->node, b->node, sizeof(uuid_t)));
 }
 --- uuid_compare.patch_2 ends here ---
 
 -- 
 Konstantin Oznobihin <bork at rsu.ru>
 System Programmer
 Computer Center of Rostov State University.
 
 


More information about the freebsd-standards mailing list