Browse Source

bgpd: fix SIGBUS

There is one test failure in the testsuite on sparc:

Running ./bgpd.tests/testbgpcap.exp ...
failed: testbgpcap ORF: ORF, simple, single entry, single tuple -- testbgpcap  aborted!

The error is a SIGBUS in bgp_capability_mp_data() because of an unaligned
memory access.  Use memcpy() instead of direct assignments.  Compilers on
platforms that support unaligned accesses should be clever enough to
optimize the function call away and do the direct store, so this should not
hurt there.
Rolf Eike Beer 1 year ago
parent
commit
adda534f95
1 changed files with 2 additions and 1 deletions
  1. 2 1
      bgpd/bgp_open.c

+ 2 - 1
bgpd/bgp_open.c

@@ -120,7 +120,8 @@ bgp_capability_vty_out (struct vty *vty, struct peer *peer)
 static void 
 bgp_capability_mp_data (struct stream *s, struct capability_mp_data *mpc)
 {
-  mpc->afi = stream_getw (s);
+  afi_t afi = stream_getw (s);
+  memcpy(&mpc->afi, &afi, sizeof(mpc->afi));
   mpc->reserved = stream_getc (s);
   mpc->safi = stream_getc (s);
 }