This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[tmoestl@gmx.net] libc/1732: Using IN6_ARE_ADDR_EQUAL as defined in netinet/in.h



FYI, I'm committing the appended patch for both branches.

Andreas


2000-05-12  Andreas Jaeger  <aj@suse.de>

	* inet/netinet/in.h (IN6_ARE_ADDR_EQUAL): Correct indices.
	Reported by tmoestl@gmx.net, closes PR libc/1732.





>Number:         1732
>Category:       libc
>Synopsis:       Using IN6_ARE_ADDR_EQUAL as defined in netinet/in.h
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    libc-gnats
>State:          open
>Class:          sw-bug
>Submitter-Id:   unknown
>Arrival-Date:   Fri May 12 09:10:01 EDT 2000
>Last-Modified:
>Originator:     tmoestl@gmx.net
>Organization:
net
>Release:        2.1.2
>Environment:
Linux 2.2.15, glibc 2.1.2
>Description:
The IN6_ARE_ADDR_EQUAL macro in netinet/in.h, line 284, seems to have a typo:
284:   #define IN6_ARE_ADDR_EQUAL(a,b) \
285:        ((((uint32_t *) (a))[0] == ((uint32_t *) (b))[0]) && \
286:         (((uint32_t *) (a))[1] == ((uint32_t *) (b))[2]) && \
287:         (((uint32_t *) (a))[2] == ((uint32_t *) (b))[1]) && \
288:         (((uint32_t *) (a))[3] == ((uint32_t *) (b))[3]))
I think that the compare must be exact, i.e. both addresses have to be equal to
the bit. Therefore, in lines 286 and 287, element 1 has to be compared with 
element 1, and element 2 has to be compared with element two.
>How-To-Repeat:
Following a test program:
-------------------------

#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>

int main()
{
	struct in6_addr a,b;
	char buf[INET6_ADDRSTRLEN];

	inet_pton(AF_INET6,"fe80::02a0:0cff:fe13:5110",&a);
	inet_pton(AF_INET6,"fe80::02a0:0cff:fe13:5110",&b);
	printf("a: %s\n",inet_ntop(AF_INET6,&a,buf,INET6_ADDRSTRLEN));
	printf("b: %s\n",inet_ntop(AF_INET6,&b,buf,INET6_ADDRSTRLEN));
	printf("a==b? %i\n",IN6_ARE_ADDR_EQUAL(&a,&b));
	return 0;
}
%0
>Fix:
>Audit-Trail:
>Unformatted:




-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.rhein-neckar.de

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]