After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 336390 - Incorrect use of the IN6_ARE_ADDR_EQUAL macro
Incorrect use of the IN6_ARE_ADDR_EQUAL macro
Status: RESOLVED FIXED
Product: gnome-vfs
Classification: Deprecated
Component: Build
cvs (head)
Other NetBSD
: Normal major
: ---
Assigned To: gnome-vfs maintainers
gnome-vfs maintainers
Depends on:
Blocks:
 
 
Reported: 2006-03-28 19:30 UTC by Julio Merino
Modified: 2006-03-28 20:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch. (1.29 KB, patch)
2006-03-28 19:31 UTC, Julio Merino
committed Details | Review

Description Julio Merino 2006-03-28 19:30:25 UTC
The libgnomevfs/gnome-vfs-address.c file uses the IN6_ARE_ADDR_EQUAL macro in a way that only works in Linux, thus breaking the build in, e.g., NetBSD or Solaris.  The problem is that the call messes with in6_addr internals by accessing their s6_addr field, which in several platforms is "mapped" to an array, not a structure.

Consider the following test program, which mimics gnome-vfs-address.c's way of calling the offending macro:

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

int
main(void)
{
        const struct sockaddr_in6 *a = NULL;
        const struct sockaddr_in6 *b = NULL;

        return IN6_ARE_ADDR_EQUAL(a->sin6_addr.s6_addr, b->sin6_addr.s6_addr);
}


Building this test case in NetBSD gives:

test.c: In function `main':
test.c:10: error: request for member `__u6_addr' in something not a structure or union
test.c:10: error: request for member `__u6_addr' in something not a structure or union

Building this test case in Solaris gives:

test.c: In function `main':
test.c:10: error: request for member `_S6_un' in something not a structure or union
test.c:10: error: request for member `_S6_un' in something not a structure or union
test.c:10: error: request for member `_S6_un' in something not a structure or union
test.c:10: error: request for member `_S6_un' in something not a structure or union
test.c:10: error: request for member `_S6_un' in something not a structure or union
test.c:10: error: request for member `_S6_un' in something not a structure or union
test.c:10: error: request for member `_S6_un' in something not a structure or union
test.c:10: error: request for member `_S6_un' in something not a structure or union

Building it in Linux works, though.

In order to fix this, the code should pass the in6_addr structure to the macro, not one of its fields, and let the macro take appropriate action.  I.e., the code above could say &a->sin6_addr instead of a->sin6_addr.s6_addr.

After applying the attached patch, the affected file builds in NetBSD, Solaris and, of course, Linux.
Comment 1 Julio Merino 2006-03-28 19:31:41 UTC
Created attachment 62238 [details] [review]
Proposed patch.
Comment 2 Julio Merino 2006-03-28 19:33:41 UTC
For what is worth modules/http-method.c and modules/http-proxy.c use the macro appropriately.  (Just discovered it.)
Comment 3 Christian Kellner 2006-03-28 19:40:24 UTC
Looks fine to me. Go ahead and commit it!
Comment 4 Julio Merino 2006-03-28 19:41:03 UTC
Sorry, I do not have commit access.  Someone else will have to do it ;-)
Comment 5 Christian Kellner 2006-03-28 20:17:54 UTC
Commited! Thanks a lot!