r36266 - in /branches/upstream/libnet-arp-perl/current: ARP.xs Changes arp.h arp.h.orig arp_lookup_bsd.c arp_lookup_linux.c get_mac_bsd.c get_mac_linux.c send_packet_bsd.c send_packet_linux.c

ryan52-guest at users.alioth.debian.org ryan52-guest at users.alioth.debian.org
Sun May 24 04:58:35 UTC 2009


Author: ryan52-guest
Date: Sun May 24 04:58:29 2009
New Revision: 36266

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=36266
Log:
[svn-upgrade] Integrating new upstream version, libnet-arp-perl (1.0.5)

Added:
    branches/upstream/libnet-arp-perl/current/arp.h.orig   (with props)
Modified:
    branches/upstream/libnet-arp-perl/current/ARP.xs
    branches/upstream/libnet-arp-perl/current/Changes
    branches/upstream/libnet-arp-perl/current/arp.h
    branches/upstream/libnet-arp-perl/current/arp_lookup_bsd.c
    branches/upstream/libnet-arp-perl/current/arp_lookup_linux.c
    branches/upstream/libnet-arp-perl/current/get_mac_bsd.c
    branches/upstream/libnet-arp-perl/current/get_mac_linux.c
    branches/upstream/libnet-arp-perl/current/send_packet_bsd.c
    branches/upstream/libnet-arp-perl/current/send_packet_linux.c

Modified: branches/upstream/libnet-arp-perl/current/ARP.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-arp-perl/current/ARP.xs?rev=36266&op=diff
==============================================================================
--- branches/upstream/libnet-arp-perl/current/ARP.xs (original)
+++ branches/upstream/libnet-arp-perl/current/ARP.xs Sun May 24 04:58:29 2009
@@ -36,12 +36,12 @@
 
 int
 send_packet(dev, sip, dip, smac, dmac, type)
-	unsigned char *dev;
-	unsigned char *sip;
-	unsigned char *dip;
-	unsigned char *smac;
-	unsigned char *dmac;
-	unsigned char *type;
+	const char *dev;
+	const char *sip;
+	const char *dip;
+	const char *smac;
+	const char *dmac;
+	const char *type;
 
 	CODE:
 	  int uid;
@@ -190,9 +190,9 @@
 
 char *
 get_mac(dev)
-	unsigned char *dev;
+	const char *dev;
 	CODE:
-          char tmp[20] = "unknown";
+          char tmp[HEX_HW_ADDR_LEN];
 
 	  if(SOCK_TYPE == SOCK_RAW)
 	  {
@@ -211,11 +211,11 @@
 
 char *
 arp_lookup(dev, ip)
-	unsigned char *dev;
-	unsigned char *ip;
+	const char *dev;
+	const char *ip;
 
 	CODE:
-	  char tmp[20] = "unknown";
+	  char tmp[HEX_HW_ADDR_LEN];
 
 	  if(SOCK_TYPE == SOCK_RAW)
 	  {

Modified: branches/upstream/libnet-arp-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-arp-perl/current/Changes?rev=36266&op=diff
==============================================================================
--- branches/upstream/libnet-arp-perl/current/Changes (original)
+++ branches/upstream/libnet-arp-perl/current/Changes Sun May 24 04:58:29 2009
@@ -1,3 +1,9 @@
+Changes between 1.0.3 and 1.0.5
+
+buffer overflow patch by Franck Joncourt <franck.mail at dthconnex.com>
+
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+
 Changes between 1.0.3 and 1.0.4
 
 fix FTBFS due to unaligned assignment problems by Niko Tyni <ntyni at debian.org>

Modified: branches/upstream/libnet-arp-perl/current/arp.h
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-arp-perl/current/arp.h?rev=36266&op=diff
==============================================================================
--- branches/upstream/libnet-arp-perl/current/arp.h (original)
+++ branches/upstream/libnet-arp-perl/current/arp.h Sun May 24 04:58:29 2009
@@ -42,6 +42,10 @@
 #endif
 #define IP_ALEN          4
 
+/* Length of the hardware address in the standard hex-digits-and-colons
+ * notation (null terminated string) */
+#define HEX_HW_ADDR_LEN  18
+
 // ARP Header Struktur
 struct my_arphdr {
    u_short hw_type;             // hardware type
@@ -56,3 +60,9 @@
 };
 
 extern struct ether_addr *ether_aton (__const char *__asc) __THROW;
+extern int get_mac_linux(const char *dev, char *mac);
+extern int get_mac_bsd(const char *dev, char *mac);
+extern int arp_lookup_linux(const char *dev, const char *ip, char *mac);
+extern int arp_lookup_bsd(const char *dev, const char *ip, char *mac);
+extern int send_packet_linux(const char *dev, u_char *packet, u_int packetsize);
+extern int send_packet_bsd(const char *dev, u_char *packet, u_int packetsize);

Added: branches/upstream/libnet-arp-perl/current/arp.h.orig
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-arp-perl/current/arp.h.orig?rev=36266&op=file
==============================================================================
--- branches/upstream/libnet-arp-perl/current/arp.h.orig (added)
+++ branches/upstream/libnet-arp-perl/current/arp.h.orig Sun May 24 04:58:29 2009
@@ -1,0 +1,58 @@
+/*
+Perl ARP Extension header file
+
+Programmed by Bastian Ballmann
+Last update: 19.12.2003
+
+This program is free software; you can redistribute 
+it and/or modify it under the terms of the 
+GNU General Public License version 2 as published 
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will 
+be useful, but WITHOUT ANY WARRANTY; without even 
+the implied warranty of MERCHANTABILITY or FITNESS 
+FOR A PARTICULAR PURPOSE. 
+See the GNU General Public License for more details. 
+*/
+
+#define ARPOP_REQUEST    1
+#define ARPOP_REPLY      2
+#define ARPOP_REVREQUEST 3
+#define ARPOP_REVREPLY   4
+#define ARPOP_INVREQUEST 8
+#define ARPOP_INVREPLY   9
+#define ARPHDR_ETHER     1
+#ifndef ETH_ALEN
+#define ETH_ALEN         6
+#endif
+#ifndef ETH_P_IP
+#define ETH_P_IP         0x0800
+#endif
+#ifndef ETH_P_ARP
+#define ETH_P_ARP        0x0806
+#endif
+#ifndef ETH_P_ALL
+#define ETH_P_ALL        0x0000
+#endif
+#ifdef BSD
+#define SOCK_TYPE        SOCK_RAW
+#else
+#define SOCK_TYPE        SOCK_PACKET
+#endif
+#define IP_ALEN          4
+
+// ARP Header Struktur
+struct my_arphdr {
+   u_short hw_type;             // hardware type
+   u_short proto_type;          // protocol type
+   u_char ha_len;               // hardware address len
+   u_char pa_len;               // protocol address len
+   u_short opcode;              // arp opcode
+   u_char source_add[ETH_ALEN]; // source mac
+   u_char source_ip[IP_ALEN];   // source ip
+   u_char dest_add[ETH_ALEN];   // dest mac
+   u_char dest_ip[IP_ALEN];     // dest ip
+};
+
+extern struct ether_addr *ether_aton (__const char *__asc) __THROW;

Propchange: branches/upstream/libnet-arp-perl/current/arp.h.orig
------------------------------------------------------------------------------
    svn:executable = *

Modified: branches/upstream/libnet-arp-perl/current/arp_lookup_bsd.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-arp-perl/current/arp_lookup_bsd.c?rev=36266&op=diff
==============================================================================
--- branches/upstream/libnet-arp-perl/current/arp_lookup_bsd.c (original)
+++ branches/upstream/libnet-arp-perl/current/arp_lookup_bsd.c Sun May 24 04:58:29 2009
@@ -28,25 +28,23 @@
 #include <netinet/if_ether.h>
 #include <arpa/inet.h>
 #include <sys/sysctl.h>
+#include <sys/types.h>
+#include "arp.h"
 
 #define ROUNDUP(a) \
         ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
 
-int arp_lookup_bsd(u_char *dev, u_char *ip, char *mac)
+int arp_lookup_bsd(const char *dev, const char *ip, char *mac)
 {
   int mib[6];
   size_t needed;
   char *lim, *buf, *next;
 
-  if(strlen(mac) > 0)
-    strcpy(mac,"unknown");
-  else
+  if ( (mac == NULL) || (dev == NULL) || (ip == NULL) )
     return -1;
 
-  if(strlen(ip) == 0)
-    return -1;
-
-  strcpy(mac,"unknown");
+  strncpy(mac,"unknown", HEX_HW_ADDR_LEN);
+  mac[HEX_HW_ADDR_LEN-1] = '\0';
 
   mib[0] = CTL_NET;
   mib[1] = PF_ROUTE;

Modified: branches/upstream/libnet-arp-perl/current/arp_lookup_linux.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-arp-perl/current/arp_lookup_linux.c?rev=36266&op=diff
==============================================================================
--- branches/upstream/libnet-arp-perl/current/arp_lookup_linux.c (original)
+++ branches/upstream/libnet-arp-perl/current/arp_lookup_linux.c Sun May 24 04:58:29 2009
@@ -20,10 +20,12 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <sys/types.h>
+#include "arp.h"
 
 #define _PATH_PROCNET_ARP "/proc/net/arp"
 
-int arp_lookup_linux(char *dev, char *ip, char *mac)
+int arp_lookup_linux(const char *dev, const char *ip, char *mac)
 {
   FILE *fp;
   char ipaddr[100];
@@ -32,18 +34,16 @@
   char mask[100];
   char device[100];
   int num, type, flags;
-  
-  if(strlen(mac) > 0)
-    strcpy(mac,"unknown");
-  else
+
+  if ( (mac == NULL) || (dev == NULL) || (ip == NULL) )
     return -1;
 
-  if(strlen(ip) == 0)
-    return -1;
-  
+  strncpy(mac,"unknown", HEX_HW_ADDR_LEN);
+  mac[HEX_HW_ADDR_LEN-1] = '\0';
+
   if ((fp = fopen(_PATH_PROCNET_ARP, "r")) == NULL) {
     perror(_PATH_PROCNET_ARP);
-    return (-1);
+    return -1;
   }
   
   /* Bypass header -- read until newline */
@@ -57,14 +57,16 @@
 	  if (num < 4)
 	    break;
 
-          if ((strlen(dev) == 0 || strcmp(dev, device) == 0) && strcmp(ip, ipaddr) == 0)
+	  else if ( ((strlen(dev) == 0) || (strcmp(dev, device) == 0))
+	      && (strcmp(ip, ipaddr) == 0) )
 	    {
-	      strcpy(mac, hwa);
+	      strncpy(mac, hwa, HEX_HW_ADDR_LEN);
+	      mac[HEX_HW_ADDR_LEN-1] = '\0';
 	      break;
 	    }
-	  strcpy(mac, "unknown");
 	}
     }
 
     fclose(fp);
+    return 0;
 }

Modified: branches/upstream/libnet-arp-perl/current/get_mac_bsd.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-arp-perl/current/get_mac_bsd.c?rev=36266&op=diff
==============================================================================
--- branches/upstream/libnet-arp-perl/current/get_mac_bsd.c (original)
+++ branches/upstream/libnet-arp-perl/current/get_mac_bsd.c Sun May 24 04:58:29 2009
@@ -30,20 +30,18 @@
 #include <net/if_dl.h>
 #include <net/if_types.h>
 #include <net/ethernet.h>
+#include "arp.h"
 
-int get_mac_bsd(u_char *dev, char *mac)
+int get_mac_bsd(const char *dev, char *mac)
 {
   struct ifaddrs *iface, *iffirst;
 
-  if(strlen(mac) > 0)
-    strcpy(mac,"unknown");
-  else
+  if ( (mac == NULL) || (dev == NULL) )
     return -1;
 
-  if(strlen(dev) == 0)
-    return -1;
+  strncpy(mac,"unknown", HEX_HW_ADDR_LEN);
+  mac[HEX_HW_ADDR_LEN-1] = '\0';
 
-  strcpy(mac,"unknown");
   if (getifaddrs(&iface))
     return -1;
 

Modified: branches/upstream/libnet-arp-perl/current/get_mac_linux.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-arp-perl/current/get_mac_linux.c?rev=36266&op=diff
==============================================================================
--- branches/upstream/libnet-arp-perl/current/get_mac_linux.c (original)
+++ branches/upstream/libnet-arp-perl/current/get_mac_linux.c Sun May 24 04:58:29 2009
@@ -21,30 +21,29 @@
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <sys/types.h>
 #include <sys/ioctl.h>
 #include <net/ethernet.h>    
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
 #include <net/if.h>
+#include "arp.h"
 
-int get_mac_linux(u_char *dev, char *mac)
+int get_mac_linux(const char *dev, char *mac)
 {
-  int sock;
+  int    sock;
   struct ifreq iface;
-  struct sockaddr_in *addr;
-  struct ether_addr ether;
-  
-  if(strlen(mac) > 0)
-    strcpy(mac,"unknown");
-  else
+
+  if ( (mac == NULL) || (dev == NULL) )
     return -1;
 
-  if(strlen(dev) == 0)
-    return -1;
-  
-  strcpy(iface.ifr_name,dev);
-  
+  /* Set hardware address as unknown */
+  strncpy(mac,"unknown", HEX_HW_ADDR_LEN);
+  mac[HEX_HW_ADDR_LEN-1] = '\0';
+
+  /* Copy device name into the ifreq strcture so that we can look for its
+   * hardware address through an ioctl request */
+  strncpy(iface.ifr_name, dev, IFNAMSIZ);
+  iface.ifr_name[IFNAMSIZ-1] = '\0';
+
   // Open a socket
   if((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
     {

Modified: branches/upstream/libnet-arp-perl/current/send_packet_bsd.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-arp-perl/current/send_packet_bsd.c?rev=36266&op=diff
==============================================================================
--- branches/upstream/libnet-arp-perl/current/send_packet_bsd.c (original)
+++ branches/upstream/libnet-arp-perl/current/send_packet_bsd.c Sun May 24 04:58:29 2009
@@ -26,7 +26,7 @@
 #include <net/if.h>
 #include "arp.h"
 
-int send_packet_bsd(u_char *dev, u_char *packet, u_int packetsize)
+int send_packet_bsd(const char *dev, u_char *packet, u_int packetsize)
 {
   int bpffd, i;
   char bpfdev[12];

Modified: branches/upstream/libnet-arp-perl/current/send_packet_linux.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-arp-perl/current/send_packet_linux.c?rev=36266&op=diff
==============================================================================
--- branches/upstream/libnet-arp-perl/current/send_packet_linux.c (original)
+++ branches/upstream/libnet-arp-perl/current/send_packet_linux.c Sun May 24 04:58:29 2009
@@ -20,16 +20,14 @@
 
 #include <string.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
 #include <sys/types.h>
 #include <sys/socket.h>      
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
 #include <arpa/inet.h>
-#include <unistd.h>
 #include "arp.h"
 
-int send_packet_linux(u_char *dev, u_char *packet, u_int packetsize)
+int send_packet_linux(const char *dev, u_char *packet, u_int packetsize)
 {
   struct sockaddr addr;
   int sock;




More information about the Pkg-perl-cvs-commits mailing list