On Fri, Apr 29, 2011 at 04:17:09PM +0200, Nicolas CARRIER wrote: > Hello, > I cross-compiled barry (precisely pppob) in order to use it on a > embedded ARM platform. Launching pppob resulted in SIGBUS caused by > alignment trap. While the simple workaround of setting up the kernel to > correct alignment worked fine (eg : echo 3 > /proc/cpu/alignment), as it > wasn't a good solution, I tried to fix the problem on the source code. > You'll find attached the corresponding patch. > I manually do compute the size with a packet[2] + 256 * packet[3] rather > than performing a cast on misaligned data.
Hi Nicolas, Thanks for the patch and bug report! Could you give the following patch a try, and let me know if it also fixes the issue for you? Thanks! - Chris diff --git a/src/probe.cc b/src/probe.cc index 3f826b8..a7a5cb0 100644 --- a/src/probe.cc +++ b/src/probe.cc @@ -29,6 +29,7 @@ #include "packet.h" #include "socket.h" #include "protocol.h" +#include "protostructs.h" #include "record-internal.h" #include "strnlen.h" #include "configfile.h" @@ -59,8 +60,8 @@ namespace { unsigned int GetSize(const unsigned char *packet) { - uint16_t size = *((uint16_t *)&packet[2]); - return btohs(size); + const Protocol::Packet *pack = (const Protocol::Packet*) packet; + return btohs(pack->size); } bool Intro(int IntroIndex, const EndpointPair &ep, Device &dev, Data &response) @@ -107,7 +108,8 @@ bool Probe::ParsePIN(const Data &data, uint32_t &pin) return false; // capture the PIN - pin = btohl(*((uint32_t *) &pd[16])); + memcpy(&pin, &pd[16], sizeof(pin)); + pin = btohl(pin); return true; } ------------------------------------------------------------------------------ WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd _______________________________________________ Barry-devel mailing list Barry-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/barry-devel