Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing unaligned accesses in sasl module

Visible for example in armv5tel, without kernel fixup for unaligned accesses.
  • Loading branch information...
commit 87cdee0438ef95a4fa8ddb5091d86c813508fbe8 1 parent c5ce73f
@viric viric authored
Showing with 11 additions and 5 deletions.
  1. +11 −5 modules/sasl.cpp
View
16 modules/sasl.cpp
@@ -114,7 +114,9 @@ class DHCommon {
}
/* Prime number */
- unsigned int size = ntohs(*(uint16_t*)data);
+ uint16_t size16;
+ memcpy(&size16, data, sizeof(size16));
+ unsigned int size = ntohs(size16);
data += 2;
length -= 2;
@@ -132,7 +134,8 @@ class DHCommon {
return false;
}
- size = ntohs(*(uint16_t*)data);
+ memcpy(&size16, data, sizeof(size16));
+ size = ntohs(size16);
data += 2;
length -= 2;
@@ -150,7 +153,8 @@ class DHCommon {
return false;
}
- size = ntohs(*(uint16_t*)data);
+ memcpy(&size16, data, sizeof(size16));
+ size = ntohs(size16);
data += 2;
length -= 2;
@@ -353,7 +357,8 @@ class CSASLMod : public CModule {
char *out_ptr = response;
/* Size of the key + key */
- *((uint16_t *)out_ptr) = htons((uint16_t)dh.key_size);
+ uint16_t size16 = htons((uint16_t)dh.key_size);
+ memcpy(out_ptr, &size16, sizeof(size16));
out_ptr += 2;
BN_bn2bin(dh.dh->pub_key, (unsigned char *)out_ptr);
out_ptr += dh.key_size;
@@ -422,7 +427,8 @@ class CSASLMod : public CModule {
out_ptr = response;
/* Add our key to the response */
- *((uint16_t *)out_ptr) = htons((uint16_t)BN_num_bytes(dh.dh->pub_key));
+ uint16_t size16 = htons((uint16_t)BN_num_bytes(dh.dh->pub_key));
+ memcpy(out_ptr, &size16, sizeof(size16));
out_ptr += 2;
BN_bn2bin(dh.dh->pub_key, (unsigned char *)out_ptr);
out_ptr += BN_num_bytes(dh.dh->pub_key);
Please sign in to comment.
Something went wrong with that request. Please try again.