mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
potential endianness fix
This commit is contained in:
@@ -40,6 +40,12 @@ namespace websocketpp {
|
||||
namespace lib {
|
||||
namespace net {
|
||||
|
||||
inline bool is_little_endian() {
|
||||
short int val = 0x1;
|
||||
char *ptr = (char*)&val;
|
||||
return (ptr[0] == 1);
|
||||
}
|
||||
|
||||
#define TYP_INIT 0
|
||||
#define TYP_SMLE 1
|
||||
#define TYP_BIGE 2
|
||||
@@ -56,7 +62,7 @@ inline uint64_t htonll(uint64_t src) {
|
||||
typ = (x.c[7] == 0x01ULL) ? TYP_BIGE : TYP_SMLE;
|
||||
}
|
||||
if (typ == TYP_BIGE)
|
||||
return src;
|
||||
return src;
|
||||
x.ull = src;
|
||||
c = x.c[0]; x.c[0] = x.c[7]; x.c[7] = c;
|
||||
c = x.c[1]; x.c[1] = x.c[6]; x.c[6] = c;
|
||||
|
||||
@@ -590,8 +590,13 @@ inline size_t prepare_masking_key(const masking_key_type& key) {
|
||||
* to zero and less than sizeof(size_t).
|
||||
*/
|
||||
inline size_t circshift_prepared_key(size_t prepared_key, size_t offset) {
|
||||
size_t temp = prepared_key << (sizeof(size_t)-offset)*8;
|
||||
return (prepared_key >> offset*8) | temp;
|
||||
if (lib::net::is_little_endian()) {
|
||||
size_t temp = prepared_key << (sizeof(size_t)-offset)*8;
|
||||
return (prepared_key >> offset*8) | temp;
|
||||
} else {
|
||||
size_t temp = prepared_key >> (sizeof(size_t)-offset)*8;
|
||||
return (prepared_key << offset*8) | temp;
|
||||
}
|
||||
}
|
||||
|
||||
/// Byte by byte mask/unmask
|
||||
|
||||
Reference in New Issue
Block a user