Nmap Development mailing list archives

Re: [NSE patch] patch for pack/unpack to use platform independant types


From: David Fifield <david () bamsoftware com>
Date: Tue, 26 Aug 2008 13:11:12 -0600

On Thu, Aug 07, 2008 at 09:37:11PM +0200, Sven Klemm wrote:
currently pack/unpack does not produce the same result across all 
platforms. The attached patch changes binlib to use platform 
independant types.

-   UNPACKSTRING(OP_BSTRING, unsigned char)
-   UNPACKSTRING(OP_WSTRING, unsigned short)
-   UNPACKSTRING(OP_SSTRING, size_t)
+   UNPACKSTRING(OP_BSTRING, u_int8_t)
+   UNPACKSTRING(OP_WSTRING, u_int16_t)
+   UNPACKSTRING(OP_SSTRING, u_int32_t)

The u_int*_t types are not the types exported by nbase. nbase uses those
types to define its own types u8, u16, u32, etc. The u_int*_t types
might be specific to Linux, and I found out today that nse_binlib.cc
doesn't compile on Solaris:

        nse_binlib.cc:172: error: `u_int8_t' was not declared in this scope
        nse_binlib.cc:172: error: expected `;' before "l"
        nse_binlib.cc:172: error: `l' was not declared in this scope
        nse_binlib.cc:172: warning: unused variable 'u_int8_t'
        nse_binlib.cc:173: error: `u_int16_t' was not declared in this scope
        nse_binlib.cc:173: error: expected `;' before "l"
        nse_binlib.cc:173: error: `l' was not declared in this scope
        nse_binlib.cc:173: warning: unused variable 'u_int16_t'

It's better to use nbase's u* and s* types for this. But nbase doesn't
define s8, u64, or s64. I have attached a patch that makes nse_binlib.cc
use nbase's integer types, defines the missing integer types in nbase,
and uses Autoconf to find the appropriate integer types, which should be
more robust than the current approach using SIZEOF_CHAR etc.

I've tested this on GNU/Linux and Solaris, but not on Windows.

David Fifield

Attachment: nbase-int-types.diff
Description:


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

Current thread: