Date: Fri, 8 Aug 2003 14:27:42 +0400 (MSD) From: Konstantin Oznobihin <bork@rsu.ru> To: FreeBSD-gnats-submit@FreeBSD.org Subject: standards/55370: [patch] uuid_compare function (uuid(3)) incorrectly compares node fields. Message-ID: <200308081027.h78ARfOi058103@rocky.cc.rsu.ru> Resent-Message-ID: <200308081030.h78AUB2c007006@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 55370 >Category: standards >Synopsis: [patch] uuid_compare function (uuid(3)) incorrectly compares node fields. >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Aug 08 03:30:10 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Konstantin Oznobihin >Release: FreeBSD 5.1-RELEASE i386 >Organization: Computer Center of Rostov State University >Environment: System: FreeBSD mymachine.somewhere.ru 5.1-RELEASE FreeBSD 5.1-RELEASE #0: Tue Jul 29 15:00:26 MSD 2003 root@mymachine.somewhere.ru:/usr/src/sys/i386/compile/KERNEL i386 >Description: When comparing two equal uuids with uuid_compare it returns -1, while according to the DCE 1.1 RPC specification it should be 0. By checking the source I found this code (see src/lib/libc/uuid/uuid_compare.c line 75): memcmp(a->node, b->node, sizeof(uuid_t)) where a and b are of type uuid_t* and the node field of the struct uuid is declared as uint8_t node[_UUID_NODE_LEN] so the size of uuid_t is always greater than size of node. >How-To-Repeat: Compile following program and run: #include <sys/cdefs.h> #include <stdio.h> #include <uuid.h> int main() { uuid_t uuid1, uuid2; int32_t ret; const char *uuid_str = "d95bc5d4-c97c-11d7-ba3d-112233445566"; uuid_from_string(uuid_str, &uuid1, NULL); uuid_from_string(uuid_str, &uuid2, NULL); ret = uuid_compare(&uuid1, &uuid2, NULL); printf("compare ret: %d\n", ret); ret = uuid_equal(&uuid1, &uuid2, NULL); printf("equal ret: %d\n", ret); return 0; } >Fix: Fix the /usr/src/lib/libc/uuid/uuid_compare.c --- uuid_compare.patch begins here --- --- uuid_compare.c Fri Aug 8 13:31:20 2003 +++ /usr/src/lib/libc/uuid/uuid_compare.c Wed Oct 30 06:51:00 2002 @@ -72,5 +72,5 @@ res = (int)a->clock_seq_low - (int)b->clock_seq_low; if (res) return ((res < 0) ? -1 : 1); - return (memcmp(a->node, b->node, _UUID_NODE_LEN)); + return (memcmp(a->node, b->node, sizeof(uuid_t))); } --- uuid_compare.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200308081027.h78ARfOi058103>