Home page logo
/

nmap-dev logo Nmap Development 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:
Author: david
Date: Sun May  8 20:21:24 2011
New Revision: 23129

Log:
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.

Modified:
   nmap-exp/david/nmap-ipv6/libdnet-stripped/src/route-bsd.c

Modified: nmap-exp/david/nmap-ipv6/libdnet-stripped/src/route-bsd.c
==============================================================================
--- 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 @@
 
 #include "dnet.h"
 
+/* 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))
 
 #ifdef HAVE_SOCKADDR_SA_LEN
 #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.

David Fifield
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]