Permalink
Browse files

Don't do a 64bit read access from a string, since it may not be 64bit…

… aligned.

Fixes crash with CPUs that require aligned access.

Signed-off-by: Timo Sirainen <tss@iki.fi>
  • Loading branch information...
sirainen authored and keithw committed Aug 11, 2012
1 parent 6201522 commit 7117b61bf4e3cd7b5ceb3381708e0ed926e08722
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/network/transportfragment.cc
@@ -78,9 +78,10 @@ Fragment::Fragment( string &x )
{
assert( x.size() >= frag_header_len );
- uint64_t *data64 = (uint64_t *)x.data();
+ uint64_t data64;
uint16_t *data16 = (uint16_t *)x.data();
- id = be64toh( data64[ 0 ] );
+ memcpy( &data64, x.data(), sizeof( data64 ) );
+ id = be64toh( data64 );
fragment_num = be16toh( data16[ 4 ] );
final = ( fragment_num & 0x8000 ) >> 15;
fragment_num &= 0x7FFF;

0 comments on commit 7117b61

Please sign in to comment.