Skip to content

Commit 30e47af

Browse files
committed
Ensure that payload pointer is appropriately aligned
to avoid bus error on RISC CPUs like SPARC. Update copyright dates. Increment version number due to display_packet() change. git-svn-id: svn+ssh://svn.nta-monitor.com/trunk/opensource/ike-scan@9884 062a1500-4a13-0410-a63b-ee65f32af78f
1 parent a4fbe43 commit 30e47af

16 files changed

+174
-77
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
$Id$
22

3+
2007-01-14 Roy Hills <Roy.Hills@nta-monitor.com>
4+
5+
* ike-scan.c: Refactored display_packet() to ensure that payload
6+
is correctly aligned.
7+
38
2007-01-13 Roy Hills <Roy.Hills@nta-monitor.com>
49

510
* check-decode: New tests for pkt-main-natt-response,

check-hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* The IKE Scanner (ike-scan) is Copyright (C) 2003-2005 Roy Hills,
2+
* The IKE Scanner (ike-scan) is Copyright (C) 2003-2007 Roy Hills,
33
* NTA Monitor Ltd.
44
*
55
* This program is free software; you can redistribute it and/or

check-sizes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* The IKE Scanner (ike-scan) is Copyright (C) 2003-2005 Roy Hills,
2+
* The IKE Scanner (ike-scan) is Copyright (C) 2003-2007 Roy Hills,
33
* NTA Monitor Ltd.
44
*
55
* This program is free software; you can redistribute it and/or

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dnl $Id$
22
dnl Process this file with autoconf to produce a configure script.
33

4-
AC_INIT([ike-scan],[1.8.7],[ike-scan@nta-monitor.com])
4+
AC_INIT([ike-scan],[1.8.8],[ike-scan@nta-monitor.com])
55
AC_PREREQ(2.59)
66
AC_REVISION($Revision$)
77
AC_CONFIG_SRCDIR([ike-scan.c])

error.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* The IKE Scanner (ike-scan) is Copyright (C) 2003-2005 Roy Hills,
2+
* The IKE Scanner (ike-scan) is Copyright (C) 2003-2007 Roy Hills,
33
* NTA Monitor Ltd.
44
*
55
* This program is free software; you can redistribute it and/or

hash_functions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* The IKE Scanner (ike-scan) is Copyright (C) 2003-2005 Roy Hills,
2+
* The IKE Scanner (ike-scan) is Copyright (C) 2003-2007 Roy Hills,
33
* NTA Monitor Ltd.
44
*
55
* This program is free software; you can redistribute it and/or

ike-backoff-patterns

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# The IKE Scanner (ike-scan) is Copyright (C) 2003-2005 Roy Hills,
1+
# The IKE Scanner (ike-scan) is Copyright (C) 2003-2007 Roy Hills,
22
# NTA Monitor Ltd.
33
#
44
# This program is free software; you can redistribute it and/or

ike-scan.c

Lines changed: 40 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* The IKE Scanner (ike-scan) is Copyright (C) 2003-2005 Roy Hills,
2+
* The IKE Scanner (ike-scan) is Copyright (C) 2003-2007 Roy Hills,
33
* NTA Monitor Ltd.
44
*
55
* This program is free software; you can redistribute it and/or
@@ -400,7 +400,7 @@ main(int argc, char *argv[]) {
400400
break;
401401
case 'V': /* --version */
402402
fprintf(stderr, "%s\n\n", PACKAGE_STRING);
403-
fprintf(stderr, "Copyright (C) 2003-2005 Roy Hills, NTA Monitor Ltd.\n");
403+
fprintf(stderr, "Copyright (C) 2003-2007 Roy Hills, NTA Monitor Ltd.\n");
404404
fprintf(stderr, "ike-scan comes with NO WARRANTY to the extent permitted by law.\n");
405405
fprintf(stderr, "You may redistribute copies of ike-scan under the terms of the GNU\n");
406406
fprintf(stderr, "General Public License.\n");
@@ -1531,6 +1531,7 @@ display_packet(int n, unsigned char *packet_in, host_entry *he,
15311531
* Process ISAKMP header.
15321532
* If this returns zero length left, indicating some sort of problem, then
15331533
* we report a short or malformed packet and return.
1534+
* If the processing is successful, pkt_ptr points to the next payload.
15341535
*/
15351536
bytes_left = n; /* Set remaining length to total packet len */
15361537
if (psk_crack_flag)
@@ -1545,6 +1546,8 @@ display_packet(int n, unsigned char *packet_in, host_entry *he,
15451546
}
15461547
/*
15471548
* Determine the overall type of the packet from the first payload type.
1549+
* We assume that pkt_ptr is suitably aligned because the ISAKMP header
1550+
* has a fixed length that is divisible by 4.
15481551
*/
15491552
switch (next) {
15501553
case ISAKMP_NEXT_SA: /* SA */
@@ -1584,58 +1587,43 @@ display_packet(int n, unsigned char *packet_in, host_entry *he,
15841587
* Process any other interesting payloads if quiet is not in effect.
15851588
*/
15861589
if (!quiet) {
1590+
unsigned char *payload_ptr;
1591+
15871592
while (bytes_left) {
1588-
if (next == ISAKMP_NEXT_VID) {
1589-
msg2=msg;
1590-
cp = process_vid(pkt_ptr, bytes_left, vidlist);
1591-
msg=make_message("%s%s%s", msg2, multiline?"\n\t":" ", cp);
1592-
free(msg2); /* Free old message */
1593-
free(cp); /* Free VID payload message */
1594-
} else if (next == ISAKMP_NEXT_ID ) {
1595-
if (psk_crack_flag)
1596-
add_psk_crack_payload(pkt_ptr, next, 'R');
1597-
msg2=msg;
1598-
cp = process_id(pkt_ptr, bytes_left);
1599-
msg=make_message("%s%s%s", msg2, multiline?"\n\t":" ", cp);
1600-
free(msg2); /* Free old message */
1601-
free(cp); /* Free ID payload message */
1602-
} else if (next == ISAKMP_NEXT_CERT || next == ISAKMP_NEXT_CR) {
1603-
msg2=msg;
1604-
cp = process_cert(pkt_ptr, bytes_left, next);
1605-
msg=make_message("%s%s%s", msg2, multiline?"\n\t":" ", cp);
1606-
free(msg2); /* Free old message */
1607-
free(cp); /* Free Cert payload message */
1608-
} else if (next == ISAKMP_NEXT_D) {
1609-
msg2=msg;
1610-
cp = process_delete(pkt_ptr, bytes_left);
1611-
msg=make_message("%s%s%s", msg2, multiline?"\n\t":" ", cp);
1612-
free(msg2); /* Free old message */
1613-
free(cp); /* Free payload message */
1614-
} else if (next == ISAKMP_NEXT_N) {
1615-
msg2=msg;
1616-
cp = process_notification(pkt_ptr, bytes_left);
1617-
msg=make_message("%s%s%s", msg2, multiline?"\n\t":" ", cp);
1618-
free(msg2); /* Free old message */
1619-
free(cp); /* Free payload message */
1620-
} else {
1621-
if (psk_crack_flag)
1622-
add_psk_crack_payload(pkt_ptr, next, 'R');
1623-
msg2=msg;
1624-
if (bytes_left >= sizeof(struct isakmp_generic)) {
1625-
struct isakmp_generic *hdr = (struct isakmp_generic *) pkt_ptr;
1626-
cp=make_message("%s(%u bytes)", id_to_name(next, payload_map),
1627-
ntohs(hdr->isag_length) -
1628-
sizeof(struct isakmp_generic));
1629-
} else {
1630-
cp=make_message("%s)", id_to_name(next, payload_map));
1631-
}
1632-
msg=make_message("%s%s%s", msg2, multiline?"\n\t":" ", cp);
1633-
free(msg2); /* Free old message */
1634-
free(cp); /* Free generic payload message */
1635-
}
1593+
payload_ptr = clone_payload(pkt_ptr, bytes_left);
1594+
msg2=msg;
1595+
switch (next) {
1596+
case ISAKMP_NEXT_VID: /* Vendor ID */
1597+
cp = process_vid(payload_ptr, bytes_left, vidlist);
1598+
break;
1599+
case ISAKMP_NEXT_ID: /* ID */
1600+
if (psk_crack_flag)
1601+
add_psk_crack_payload(payload_ptr, next, 'R');
1602+
cp = process_id(payload_ptr, bytes_left);
1603+
break;
1604+
case ISAKMP_NEXT_CERT: /* Certificate */
1605+
case ISAKMP_NEXT_CR: /* Certificate Request */
1606+
cp = process_cert(payload_ptr, bytes_left, next);
1607+
break;
1608+
case ISAKMP_NEXT_D: /* Delete */
1609+
cp = process_delete(payload_ptr, bytes_left);
1610+
break;
1611+
case ISAKMP_NEXT_N: /* Notification */
1612+
cp = process_notification(payload_ptr, bytes_left);
1613+
break;
1614+
default: /* Something else */
1615+
if (psk_crack_flag)
1616+
add_psk_crack_payload(payload_ptr, next, 'R');
1617+
cp = process_generic(payload_ptr, bytes_left, next);
1618+
break;
1619+
} /* End Switch */
1620+
free(payload_ptr);
1621+
msg=make_message("%s%s%s", msg2, multiline?"\n\t":" ", cp);
1622+
free(msg2); /* Free old message */
1623+
free(cp); /* Free payload message */
16361624
pkt_ptr = skip_payload(pkt_ptr, &bytes_left, &next);
1637-
}
1638-
}
1625+
} /* End While */
1626+
} /* End if (!quiet) */
16391627
/*
16401628
* Print the message.
16411629
*/

ike-scan.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* The IKE Scanner (ike-scan) is Copyright (C) 2003-2005 Roy Hills,
2+
* The IKE Scanner (ike-scan) is Copyright (C) 2003-2007 Roy Hills,
33
* NTA Monitor Ltd.
44
*
55
* This program is free software; you can redistribute it and/or
@@ -420,6 +420,7 @@ char *process_id(unsigned char *, size_t);
420420
char *process_cert(unsigned char *, size_t, unsigned);
421421
char *process_delete(unsigned char *, size_t);
422422
char *process_notification(unsigned char *, size_t);
423+
char *process_generic(unsigned char *, size_t, unsigned);
423424
unsigned char *make_transform(size_t *, unsigned, unsigned, unsigned,
424425
unsigned char *, size_t);
425426
unsigned char* add_transform(int, size_t *, unsigned, unsigned char *, size_t);
@@ -431,6 +432,7 @@ unsigned char *add_isakmp_payload(unsigned char *, size_t, unsigned char **);
431432
void print_payload(unsigned char *cp, unsigned payload, int);
432433
void add_psk_crack_payload(unsigned char *cp, unsigned, int);
433434
void print_psk_crack_values(const char *);
435+
unsigned char *clone_payload(const unsigned char *, size_t);
434436
char *make_message(const char *, ...);
435437
char *numstr(unsigned);
436438
char *printable(const unsigned char*, size_t);

ike-vendor-ids

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# The IKE Scanner (ike-scan) is Copyright (C) 2003-2005 Roy Hills,
1+
# The IKE Scanner (ike-scan) is Copyright (C) 2003-2007 Roy Hills,
22
# NTA Monitor Ltd.
33
#
44
# This program is free software; you can redistribute it and/or

0 commit comments

Comments
 (0)