mailing list archives
Re: [nmap-svn] r23129 - nmap-exp/david/nmap-ipv6/libdnet-stripped/src
From: David Fifield <david () bamsoftware com>
Date: Sun, 8 May 2011 20:24:04 -0700
On Sun, May 08, 2011 at 08:21:24PM -0700, commit-mailer () insecure org wrote:
Date: Sun May 8 20:21:24 2011
New Revision: 23129
Use 4-byte sockaddr alignment, not 8-byte, in rt_msghdr.
4 bytes seems to be the right number on OS X, despite Unix Network
Programming that states 8 bytes.
--- nmap-exp/david/nmap-ipv6/libdnet-stripped/src/route-bsd.c (original)
+++ nmap-exp/david/nmap-ipv6/libdnet-stripped/src/route-bsd.c Sun May 8 20:21:24 2011
@@ -43,8 +43,14 @@
+/* Unix Network Programming, 3rd edition says that sockaddr structures in
+ rt_msghdr should be padded so their addresses start on a multiple of
+ sizeof(u_long). But on 64-bit Mac OS X 10.6 at least, this is false. Apple's
+ netstat code uses 4-byte padding, not 8-byte. This is relevant for IPv6
+ addresses, for which sa_len == 28.
+ http://www.opensource.apple.com/source/network_cmds/network_cmds-329.2.2/netstat.tproj/route.c */
#define ROUNDUP(a) \
- ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
+ ((a) > 0 ? (1 + (((a) - 1) | (sizeof(uint32_t) - 1))) : sizeof(uint32_t))
#define NEXTSA(s) \
I spent a few hours tracking this down to make routes work in the IPv6
branch. I am not sure this patch is universally right, because every
source that I've found, except for Apple's source code, says that this
rounding should be to sizeof(unsigned long), which on this platform is 8
bytes. But 8 bytes definitely doesn't work for me, and 4 bytes does.
I emailed the libdnet maintainers to see if they have any insight.
Sent through the nmap-dev mailing list
Archived at http://seclists.org/nmap-dev/
- Re: [nmap-svn] r23129 - nmap-exp/david/nmap-ipv6/libdnet-stripped/src David Fifield (May 09)