Bug#390020: libnet-arp-perl: FTBFS: *** [test_dynamic] Segmentation
fault
Niko Tyni
ntyni at iki.fi
Thu Oct 5 18:31:55 UTC 2006
tag 390020 patch
thanks
On Thu, Sep 28, 2006 at 10:56:23PM +0200, Kurt Roeckx wrote:
> Package: libnet-arp-perl
> Version: 0.8-1
> Severity: important
> Your package is failing to build with the following error:
> PERL_DL_NONLAZY=1 /usr/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl
> make[1]: *** [test_dynamic] Segmentation fault
> make[1]: Leaving directory `/build/buildd/libnet-arp-perl-0.8'
>
> It looks like you're having this problem on 64 bit arches.
It actually looks like an alignment problem, at least on sparc.
And alpha is OK, FWIW.
> Also, notice the following warnings in the buildd log:
> ARP.xs:120: warning: implicit declaration of function 'ether_aton'
> ARP.xs:120: warning: cast to pointer from integer of different size
[...]
Here's a patch that fixes both of these issues.
Cheers,
--
Niko Tyni ntyni at iki.fi
-------------- next part --------------
diff -u libnet-arp-perl-0.8/debian/changelog libnet-arp-perl-0.8/debian/changelog
only in patch2:
unchanged:
--- libnet-arp-perl-0.8.orig/ARP.xs
+++ libnet-arp-perl-0.8/ARP.xs
@@ -27,6 +27,7 @@
#include <string.h>
#include <errno.h>
#include <net/ethernet.h>
+#include <netinet/ether.h>
#include <net/if.h>
#include <arpa/inet.h>
#include "arp.h"
@@ -44,11 +45,12 @@
CODE:
int uid;
- unsigned int packetsize = sizeof(struct arphdr) + sizeof(struct ether_header);
+ unsigned int packetsize = sizeof(struct my_arphdr) + sizeof(struct ether_header);
unsigned char packet[packetsize];
struct ether_header *ethhdr = (struct ether_header *)packet;
- struct arphdr *arp = (struct arphdr *)(packet + sizeof(struct ether_header));
+ struct my_arphdr *arp = (struct my_arphdr *)(packet + sizeof(struct ether_header));
u_short op;
+ in_addr_t ipaddr;
// Are you root?
uid = getuid();
@@ -128,12 +130,14 @@
arp->pa_len = IP_ALEN; // Protocol address length
arp->opcode = htons(op); // ARP operation
memcpy(arp->source_add,(u_char *)ether_aton(smac),ETH_ALEN); // Source MAC
- *(u_long *)arp->source_ip = inet_addr(sip); // Source IP
+ ipaddr = inet_addr(sip);
+ memcpy(arp->source_ip, (u_char *)&ipaddr, IP_ALEN); // Source IP
if(strcmp(dmac,"ff:ff:ff:ff:ff:ff"))
memcpy(arp->dest_add,(u_char *)ether_aton(dmac),ETH_ALEN); // Destination MAC
- *(u_long *)arp->dest_ip = inet_addr(dip); // Destination IP
+ ipaddr = inet_addr(dip);
+ memcpy(arp->dest_ip, (u_char *)&ipaddr, IP_ALEN); // Destination IP
// Run packet!! Run!
only in patch2:
unchanged:
--- libnet-arp-perl-0.8.orig/arp.h
+++ libnet-arp-perl-0.8/arp.h
@@ -43,7 +43,7 @@
#define IP_ALEN 4
// ARP Header Struktur
-struct arphdr {
+struct my_arphdr {
u_short hw_type; // hardware type
u_short proto_type; // protocol type
u_char ha_len; // hardware address len
only in patch2:
unchanged:
--- libnet-arp-perl-0.8.orig/arp_lookup_linux.c
+++ libnet-arp-perl-0.8/arp_lookup_linux.c
@@ -19,6 +19,7 @@
*/
#include <stdio.h>
+#include <string.h>
#define _PATH_PROCNET_ARP "/proc/net/arp"
only in patch2:
unchanged:
--- libnet-arp-perl-0.8.orig/get_mac_linux.c
+++ libnet-arp-perl-0.8/get_mac_linux.c
@@ -20,6 +20,9 @@
#include <sys/ioctl.h>
#include <net/ethernet.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
#include <net/if.h>
int get_mac_linux(u_char *dev, char *mac)
only in patch2:
unchanged:
--- libnet-arp-perl-0.8.orig/send_packet_linux.c
+++ libnet-arp-perl-0.8/send_packet_linux.c
@@ -20,6 +20,9 @@
#include <sys/types.h>
#include <sys/socket.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
#include "arp.h"
int send_packet_linux(u_char *dev, u_char *packet, u_int packetsize)
More information about the pkg-perl-maintainers
mailing list