Re: weird error messages
> Same kind of problem with nmap :)
>
> Feb 9 16:12:22 hot kernel: nmap(2999): unaligned trap at 00000001200106bc: 000000012008d8fe 28 2
> Feb 9 16:14:31 hot kernel: nmap(3003): unaligned trap at 00000001200106bc: 000000012008d8fe 28 2
> Feb 9 16:14:31 hot kernel: nmap(3003): unaligned trap at 00000001200106e0: 000000012008d8fe 28 2
> Feb 9 16:14:31 hot kernel: nmap(3003): unaligned trap at 0000000120010940: 000000012008d90a 28 3
Try this patch for nmap (below). I wrote it awhile ago and really don't
know if it'll fix the above problems, but it's possible that the regular
maintainer dumped my patches in the past...
diff -ruN nmap-2.12/osscan.c nmap-patched/osscan.c
--- nmap-2.12/osscan.c Sun Apr 4 03:45:41 1999
+++ nmap-patched/osscan.c Thu Jul 6 19:43:25 2000
@@ -23,7 +23,7 @@
int testsleft;
int testno;
int timeout;
-unsigned long sequence_base;
+unsigned int sequence_base;
unsigned int openport;
int bytes;
unsigned int closedport;
@@ -34,15 +34,15 @@
char err0r[PCAP_ERRBUF_SIZE];
char filter[512];
double seq_inc_sum = 0;
-unsigned long seq_avg_inc = 0;
+unsigned int seq_avg_inc = 0;
struct udpprobeinfo *upi = NULL;
-unsigned long seq_gcd = 1;
-unsigned long seq_diffs[NUM_SEQ_SAMPLES];
+unsigned int seq_gcd = 1;
+unsigned int seq_diffs[NUM_SEQ_SAMPLES];
int ossofttimeout, oshardtimeout;
/* Init our fingerprint tests to each be NULL */
bzero(FPtests, sizeof(FPtests));
-get_random_bytes(&sequence_base, sizeof(unsigned long));
+get_random_bytes(&sequence_base, sizeof(unsigned int));
/* Init our raw socket */
if ((rawsd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0 )
pfatal("socket trobles in get_fingerprint");
@@ -310,9 +310,9 @@
/* Some versions of libc seem to have broken pow ... so we
avoid it */
#ifdef LINUX
- si->index = (unsigned long) (0.5 + sqrt(seq_inc_sum));
+ si->index = (unsigned int) (0.5 + sqrt(seq_inc_sum));
#else
- si->index = (unsigned long) (0.5 + pow(seq_inc_sum, 0.5));
+ si->index = (unsigned int) (0.5 + pow(seq_inc_sum, 0.5));
#endif
/* printf("The sequence index is %d\n", si->index);*/
if (si->index < 75) {
@@ -348,7 +348,7 @@
strcpy(seq_AVs[0].value, "TD");
seq_AVs[0].next = &seq_AVs[1];
seq_AVs[1].attribute= "gcd";
- sprintf(seq_AVs[1].value, "%lX", seq_gcd);
+ sprintf(seq_AVs[1].value, "%dX", seq_gcd);
seq_AVs[1].next = &seq_AVs[2];
seq_AVs[2].attribute="SI";
sprintf(seq_AVs[2].value, "%X", si->index);
@@ -357,7 +357,7 @@
strcpy(seq_AVs[0].value, "RI");
seq_AVs[0].next = &seq_AVs[1];
seq_AVs[1].attribute= "gcd";
- sprintf(seq_AVs[1].value, "%lX", seq_gcd);
+ sprintf(seq_AVs[1].value, "%dX", seq_gcd);
seq_AVs[1].next = &seq_AVs[2];
seq_AVs[2].attribute="SI";
sprintf(seq_AVs[2].value, "%X", si->index);
@@ -407,7 +407,7 @@
}
-struct AVal *fingerprint_iptcppacket(struct ip *ip, int mss, unsigned long syn) {
+struct AVal *fingerprint_iptcppacket(struct ip *ip, int mss, unsigned int syn) {
struct AVal *AVs;
int length;
int opcode;
@@ -581,8 +581,8 @@
int AVal_match(struct AVal *reference, struct AVal *fprint) {
struct AVal *current_ref;
struct AVal *current_fp;
- unsigned long number;
- unsigned long val;
+ unsigned int number;
+ unsigned int val;
char *p, *q; /* OHHHH YEEEAAAAAHHHH!#!@#$!% */
char valcpy[512];
char *endptr;
@@ -804,7 +804,7 @@
}
-unsigned long get_gcd_n_ulong(int numvalues, unsigned long *values) {
+unsigned int get_gcd_n_ulong(int numvalues, unsigned int *values) {
int gcd;
int i;
@@ -816,7 +816,7 @@
return gcd;
}
-unsigned long euclid_gcd(unsigned long a, unsigned long b) {
+unsigned int euclid_gcd(unsigned int a, unsigned int b) {
if (a < b) return euclid_gcd(b,a);
if (!b) return a;
return euclid_gcd(b, a % b);
diff -ruN nmap-2.12/osscan.h nmap-patched/osscan.h
--- nmap-2.12/osscan.h Sun Apr 4 00:32:49 1999
+++ nmap-patched/osscan.h Thu Jul 6 19:30:34 2000
@@ -15,13 +15,13 @@
/********************** PROTOTYPES ***********************************/
int os_scan(struct hoststruct *target);
FingerPrint *get_fingerprint(struct hoststruct *target, struct seq_info *si);
-struct AVal *fingerprint_iptcppacket(struct ip *ip, int mss, unsigned long syn);
+struct AVal *fingerprint_iptcppacket(struct ip *ip, int mss, unsigned int syn);
struct AVal *fingerprint_portunreach(struct ip *ip, struct udpprobeinfo *upi);
struct udpprobeinfo *send_closedudp_probe(int rawsd, struct in_addr *dest,
unsigned short sport, unsigned short
dport);
-unsigned long get_gcd_n_ulong(int numvalues, unsigned long *values);
-unsigned long euclid_gcd(unsigned long a, unsigned long b);
+unsigned int get_gcd_n_ulong(int numvalues, unsigned int *values);
+unsigned int euclid_gcd(unsigned int a, unsigned int b);
char *fp2ascii(FingerPrint *FP);
FingerPrint **parse_fingerprint_reference_file();
FingerPrint **match_fingerprint(FingerPrint *FP, int *matches_found);
diff -ruN nmap-2.12/tcpip.c nmap-patched/tcpip.c
--- nmap-2.12/tcpip.c Sun Mar 21 19:58:04 1999
+++ nmap-patched/tcpip.c Thu Jul 6 19:43:01 2000
@@ -46,7 +46,7 @@
/* Standard swiped internet checksum routine */
inline unsigned short in_cksum(unsigned short *ptr,int nbytes) {
-register long sum; /* assumes long == 32 bits */
+register int sum; /* assumes long == 32 bits */
u_short oddbyte;
register u_short answer; /* assumes u_short == 16 bits */
@@ -102,16 +102,16 @@
int send_tcp_raw( int sd, struct in_addr *source,
struct in_addr *victim, unsigned short sport,
- unsigned short dport, unsigned long seq,
- unsigned long ack, unsigned char flags,
+ unsigned short dport, unsigned int seq,
+ unsigned int ack, unsigned char flags,
unsigned short window, char *options, int optlen,
char *data, unsigned short datalen)
{
struct pseudo_header {
/*for computing TCP checksum, see TCP/IP Illustrated p. 145 */
- unsigned long s_addy;
- unsigned long d_addr;
+ unsigned int s_addy;
+ unsigned int d_addr;
char zer0;
unsigned char protocol;
unsigned short length;
@@ -318,10 +318,10 @@
printf("ttl: %hu ", ip->ip_ttl);
- if (tcp->th_flags & (TH_SYN | TH_ACK)) printf("Seq: %lu\tAck: %lu\n",
- (unsigned long) ntohl(tcp->th_seq), (unsigned long) ntohl(tcp->th_ack));
- else if (tcp->th_flags & TH_SYN) printf("Seq: %lu\n", (unsigned long) ntohl(tcp->th_seq));
- else if (tcp->th_flags & TH_ACK) printf("Ack: %lu\n", (unsigned long) ntohl(tcp->th_ack));
+ if (tcp->th_flags & (TH_SYN | TH_ACK)) printf("Seq: %du\tAck: %du\n",
+ (unsigned int) ntohl(tcp->th_seq), (unsigned int) ntohl(tcp->th_ack));
+ else if (tcp->th_flags & TH_SYN) printf("Seq: %du\n", (unsigned int) ntohl(tcp->th_seq));
+ else if (tcp->th_flags & TH_ACK) printf("Ack: %du\n", (unsigned int) ntohl(tcp->th_ack));
}
}
if (readdata && i < tot_len) {
@@ -757,7 +757,7 @@
in pcap_open_live()
*/
-char *readip_pcap(pcap_t *pd, unsigned int *len, long to_usec) {
+char *readip_pcap(pcap_t *pd, unsigned int *len, int to_usec) {
static int offset = -1;
static pcap_t *lastpcap = NULL;
struct pcap_pkthdr head;
@@ -828,7 +828,7 @@
/* Like readip_pcap except we use our own timeout value. This is needed
due to a "bug" in libpcap. The Linux pcap_open_live takes a timeout
but DOES NOT EVEN LOOK AT IT! */
-char *readip_pcap_timed(pcap_t *pd, unsigned int *len, unsigned long timeout /*seconds
+char *readip_pcap_timed(pcap_t *pd, unsigned int *len, unsigned int timeout /*seconds
*/) {
static int offset = -1;
static pcap_t *lastpcap = NULL;
@@ -936,12 +936,15 @@
fatal("getinterfaces: SIOCGIFCONF claims you have no network interfaces!\n");
#if HAVE_SOCKADDR_SA_LEN
/* len = MAX(sizeof(struct sockaddr), ifr->ifr_addr.sa_len);*/
- len = ifr->ifr_addr.sa_len;
+ len = ifr->ifr_addr.sa_len + sizeof(ifr->ifr_name);
#else
- len = sizeof(SA);
+ len = sizeof(struct ifreq);
+/* len = sizeof(SA); */
#endif
for(; ifr && *((char *)ifr) && ((char *)ifr) < buf + ifc.ifc_len;
- ((*(char **)&ifr) += sizeof(ifr->ifr_name) + len )) {
+ ((*(char **)&ifr) += len )) {
+ if (!*((char *)ifr))
+ continue;
sin = (struct sockaddr_in *) &ifr->ifr_addr;
memcpy(&(mydevs[numinterfaces].addr), (char *) &(sin->sin_addr), sizeof(struct in_addr));
/* In case it is a stinkin' alias */
@@ -956,7 +959,7 @@
}
#if HAVE_SOCKADDR_SA_LEN
/* len = MAX(sizeof(struct sockaddr), ifr->ifr_addr.sa_len);*/
- len = ifr->ifr_addr.sa_len;
+ len = ifr->ifr_addr.sa_len + sizeof(ifr->ifr_name);
#endif
mydevs[numinterfaces].name[0] = '\0';
}
@@ -982,8 +985,8 @@
struct interface_info *mydevs;
static struct myroute {
struct interface_info *dev;
- unsigned long mask;
- unsigned long dest;
+ unsigned int mask;
+ unsigned int dest;
} myroutes[128];
int numinterfaces = 0;
char *p, *endptr;
@@ -1021,7 +1024,7 @@
}
p = strtok(NULL, " \t\n");
endptr = NULL;
- myroutes[numroutes].dest = strtol(p, &endptr, 16);
+ myroutes[numroutes].dest = strtoul(p, &endptr, 16);
if (!endptr || *endptr) {
error("Failed to determine Destination from /proc/net/route");
continue;
@@ -1035,7 +1038,7 @@
continue;
}
endptr = NULL;
- myroutes[numroutes].mask = strtol(p, &endptr, 16);
+ myroutes[numroutes].mask = strtoul(p, &endptr, 16);
if (!endptr || *endptr) {
error("Failed to determine mask from /proc/net/route");
continue;
diff -ruN nmap-2.12/tcpip.h nmap-patched/tcpip.h
--- nmap-2.12/tcpip.h Sat Mar 20 22:09:00 1999
+++ nmap-patched/tcpip.h Thu Jul 6 19:36:56 2000
@@ -290,8 +290,8 @@
unsigned short in_cksum(unsigned short *ptr,int nbytes);
int send_tcp_raw( int sd, struct in_addr *source,
struct in_addr *victim, unsigned short sport,
- unsigned short dport, unsigned long seq,
- unsigned long ack, unsigned char flags,
+ unsigned short dport, unsigned int seq,
+ unsigned int ack, unsigned char flags,
unsigned short window, char *options, int optlen,
char *data, unsigned short datalen);
int send_udp_raw( int sd, struct in_addr *source,
@@ -324,8 +324,8 @@
unsigned short in_cksum(unsigned short *ptr,int nbytes);
/* Hex dump */
int get_link_offset(char *device);
-char *readip_pcap(pcap_t *pd, unsigned int *len, long to_usec);
-char *readip_pcap_timed(pcap_t *pd, unsigned int *len, unsigned long timeout /*seconds
+char *readip_pcap(pcap_t *pd, unsigned int *len, int to_usec);
+char *readip_pcap_timed(pcap_t *pd, unsigned int *len, unsigned int timeout /*seconds
*/);
#ifndef HAVE_INET_ATON
int inet_aton(register const char *, struct in_addr *);
Reply to: