fa49311
diff -urp pads-1.2.orig/src/mac-resolution.c pads-1.2/src/mac-resolution.c
fa49311
--- pads-1.2.orig/src/mac-resolution.c	2008-06-30 13:56:52.000000000 -0400
fa49311
+++ pads-1.2/src/mac-resolution.c	2008-07-07 12:07:36.000000000 -0400
fa49311
@@ -160,7 +160,7 @@ int add_vendor (char *mac, char *vendor)
fa49311
  * INPUT        : 0 - MAC Address
fa49311
  * RETURN       : Vendor Name
fa49311
  * ---------------------------------------------------------- */
fa49311
-bstring get_vendor (char *m)
fa49311
+bstring get_vendor (const char *m)
fa49311
 {
fa49311
     Vendor *list;
fa49311
     char mac[4];
fa49311
diff -urp pads-1.2.orig/src/mac-resolution.h pads-1.2/src/mac-resolution.h
fa49311
--- pads-1.2.orig/src/mac-resolution.h	2008-06-29 20:16:30.000000000 -0400
fa49311
+++ pads-1.2/src/mac-resolution.h	2008-07-07 12:07:36.000000000 -0400
fa49311
@@ -41,7 +41,7 @@
fa49311
 int init_mac_resolution (void);
fa49311
 int parse_raw_mac (bstring line);
fa49311
 int add_vendor (char *mac, char *vendor);
fa49311
-bstring get_vendor (char *m);
fa49311
+bstring get_vendor (const char *m);
fa49311
 void end_mac_resolution (void);
fa49311
 
fa49311
 #ifdef DEBUG
fa49311
diff -urp pads-1.2.orig/src/output/output-csv.c pads-1.2/src/output/output-csv.c
fa49311
--- pads-1.2.orig/src/output/output-csv.c	2008-07-02 09:24:19.000000000 -0400
fa49311
+++ pads-1.2/src/output/output-csv.c	2008-07-07 12:07:36.000000000 -0400
fa49311
@@ -91,6 +91,7 @@ init_output_csv (bstring filename)
fa49311
 	/* File does not exist, create new.. */
fa49311
 	if ((output_csv_conf.file = fopen((char *)bdata(output_csv_conf.filename), "w")) != NULL) {
fa49311
 	    fprintf(output_csv_conf.file, "asset,port,proto,service,application,discovered\n");
fa49311
+	    fflush(output_csv_conf.file);
fa49311
 
fa49311
 	} else {
fa49311
 	    err_message("Cannot open file %s!", bdata(output_csv_conf.filename));
fa49311
@@ -216,8 +217,11 @@ parse_raw_report (bstring line)
fa49311
     /* Add Asset to Data Structure */
fa49311
     if (proto == 0 && ret != -1) {
fa49311
 	/* ARP */
fa49311
-	mac2hex((char *)bdata(application), mac_addr, MAC_LEN);
fa49311
-	add_arp_asset(ip_addr, mac_addr, discovered);
fa49311
+	if (mac2hex((char *)bdata(application), mac_addr, MAC_LEN) == 0)
fa49311
+		add_arp_asset(ip_addr, mac_addr, discovered);
fa49311
+	else
fa49311
+		log_message("Error parsing HWaddr %s - skipping", 
fa49311
+			(char *)bdata(application));
fa49311
     } else {
fa49311
 	/* Everything Else */
fa49311
 	add_asset(ip_addr, port, proto, service, application, discovered);
fa49311
diff -urp pads-1.2.orig/src/storage.c pads-1.2/src/storage.c
fa49311
--- pads-1.2.orig/src/storage.c	2008-06-30 17:54:33.000000000 -0400
fa49311
+++ pads-1.2/src/storage.c	2008-07-07 12:07:36.000000000 -0400
fa49311
@@ -108,7 +108,7 @@ int check_arp_asset (struct in_addr ip_a
fa49311
     rec = arp_asset_list;
fa49311
     while (rec != NULL) {
fa49311
 	if (rec->ip_addr.s_addr == ip_addr.s_addr
fa49311
-		&& (strcmp(rec->mac_addr, mac_addr) == 0)) {
fa49311
+		&& (memcmp(rec->mac_addr, mac_addr, MAC_LEN) == 0)) {
fa49311
 	    return 0;
fa49311
 
fa49311
 	} else {
fa49311
@@ -200,7 +200,7 @@ void add_asset (struct in_addr ip_addr,
fa49311
  *		: 2 - Discovered
fa49311
  * RETURN	: None!
fa49311
  * ---------------------------------------------------------- */
fa49311
-void add_arp_asset (struct in_addr ip_addr, char mac_addr[MAC_LEN],
fa49311
+void add_arp_asset (struct in_addr ip_addr, const char *mac_addr,
fa49311
 		    time_t discovered)
fa49311
 {
fa49311
     ArpAsset *list;
fa49311
diff -urp pads-1.2.orig/src/storage.h pads-1.2/src/storage.h
fa49311
--- pads-1.2.orig/src/storage.h	2008-06-29 20:16:30.000000000 -0400
fa49311
+++ pads-1.2/src/storage.h	2008-07-07 12:07:36.000000000 -0400
fa49311
@@ -52,7 +52,7 @@ int check_tcp_asset (struct in_addr ip_a
fa49311
 int check_icmp_asset (struct in_addr ip_addr);
fa49311
 int check_arp_asset (struct in_addr ip_addr, char mac_addr[MAC_LEN]);
fa49311
 void add_asset (struct in_addr ip_addr, u_int16_t port, unsigned short proto, bstring service, bstring application, time_t discovered);
fa49311
-void add_arp_asset (struct in_addr ip_addr, char mac_addr[MAC_LEN], time_t discovered);
fa49311
+void add_arp_asset (struct in_addr ip_addr, const char *mac_addr, time_t discovered);
fa49311
 unsigned short get_i_attempts (struct in_addr ip_addr, u_int16_t port, unsigned short proto);
fa49311
 short update_i_attempts (struct in_addr ip_addr, u_int16_t port, unsigned short proto, unsigned short i_attempts);
fa49311
 short update_asset (struct in_addr ip_addr, u_int16_t port, unsigned short proto, bstring service, bstring application);
fa49311
diff -urp pads-1.2.orig/src/util.c pads-1.2/src/util.c
fa49311
--- pads-1.2.orig/src/util.c	2008-07-02 09:24:19.000000000 -0400
fa49311
+++ pads-1.2/src/util.c	2008-07-07 12:08:00.000000000 -0400
fa49311
@@ -27,6 +27,7 @@
fa49311
  **************************************************************************/
fa49311
 #include <unistd.h>
fa49311
 #include <ctype.h>
fa49311
+#include <errno.h>
fa49311
 #include "util.h"
fa49311
 #include "pads.h"
fa49311
 
fa49311
@@ -426,31 +427,39 @@ drop_privs (bstring newuser, bstring new
fa49311
  * INPUT        : 0 - MAC Address
fa49311
  *              : 1 - Converted
fa49311
  *              : 0 - Size of 1
fa49311
- * RETURN       : None
fa49311
+ * RETURN       : 0 - success, -1 failure
fa49311
  * ---------------------------------------------------------- */
fa49311
-void
fa49311
+int
fa49311
 mac2hex(const char *mac, char *dst, int len)
fa49311
 {
fa49311
     int i;
fa49311
-    long l;
fa49311
-    char *pp;
fa49311
+    unsigned long l;
fa49311
 
fa49311
     if (len < 6)
fa49311
-        return;
fa49311
+        return -1;
fa49311
 
fa49311
     while (isspace(*mac))
fa49311
         mac++;
fa49311
 
fa49311
     /* expect 6 hex octets separated by ':' or space/NUL if last octet */
fa49311
-    for (i = 0; i < 6; i++) {
fa49311
-        l = strtol(mac, &pp, 16);
fa49311
-        if (pp == mac || l > 0xFF || l < 0)
fa49311
-            return;
fa49311
-        if (!(*pp == ':' || (i == 5 && (isspace(*pp) || *pp == '\0'))))
fa49311
-            return;
fa49311
-        dst[i] = (u_char) l;
fa49311
-        mac = pp + 1;
fa49311
+    for (i = 0; i < MAC_LEN; i++) {
fa49311
+        char tmp[3];
fa49311
+
fa49311
+        while (*mac == ':' || *mac == ' ')
fa49311
+            mac++;
fa49311
+        if (mac[0] == 0 || mac[1] == 0)
fa49311
+            return -1;
fa49311
+        tmp[0] = mac[0];
fa49311
+        tmp[1] = mac[1];
fa49311
+        tmp[2] = 0;
fa49311
+        errno = 0;
fa49311
+        l = strtoul(tmp, NULL, 16);
fa49311
+        if (errno)
fa49311
+            return -1;
fa49311
+        dst[i] = (u_char)(l & 0xFF);
fa49311
+        mac+=2;
fa49311
     }
fa49311
+    return 0;
fa49311
 }
fa49311
 
fa49311
 /* ----------------------------------------------------------
fa49311
@@ -464,11 +473,11 @@ mac2hex(const char *mac, char *dst, int 
fa49311
 char *
fa49311
 hex2mac(const char *mac)
fa49311
 {
fa49311
-    static char buf[18];
fa49311
+    static char buf[32];
fa49311
 
fa49311
     snprintf(buf, sizeof(buf), "%02X:%02X:%02X:%02X:%02X:%02X",
fa49311
-        mac[0], mac[1], mac[2],
fa49311
-        mac[3], mac[4], mac[5]);
fa49311
+        (mac[0] & 0xFF) , (mac[1] & 0xFF), (mac[2] & 0xFF),
fa49311
+        (mac[3] & 0xFF), (mac[4] & 0xFF), (mac[5] & 0xFF));
fa49311
 
fa49311
     return buf;
fa49311
 }
fa49311
diff -urp pads-1.2.orig/src/util.h pads-1.2/src/util.h
fa49311
--- pads-1.2.orig/src/util.h	2008-06-30 13:56:52.000000000 -0400
fa49311
+++ pads-1.2/src/util.h	2008-07-07 12:07:36.000000000 -0400
fa49311
@@ -52,7 +52,7 @@ size_t strlcpy(char *dst, const char *sr
fa49311
 size_t strlcat(char *dst, const char *src, size_t len);
fa49311
 #endif
fa49311
 void drop_privs (bstring newuser, bstring newgroup);
fa49311
-void mac2hex(const char *mac, char *dst, int len);
fa49311
+int mac2hex(const char *mac, char *dst, int len);
fa49311
 char *hex2mac(const char *mac);
fa49311
 
fa49311
 /* GLOBALS ----------------------------------------- */