From f110b0bc6590e13116d993e5f36af697577ddecb Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Tue, 30 Apr 2013 17:14:34 -0500 Subject: [PATCH] potential solution for PPC masking bug --- websocketpp/frame.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocketpp/frame.hpp b/websocketpp/frame.hpp index fe430db0ad..0ab8976e50 100644 --- a/websocketpp/frame.hpp +++ b/websocketpp/frame.hpp @@ -749,10 +749,11 @@ inline size_t word_mask_circ(uint8_t* input, uint8_t* output, size_t length, } // mask partial word at the end - if (l > 0) { - size_t r = 8*(sizeof(size_t) - l); // convert from bytes to bits - output_word[n] = input_word[n] ^ ((prepared_key << r) >> r); - } + size_t start = length - l; + char * test = reinterpret_cast(&prepared_key); + for (size_t i = 0; i < l; ++i) { + output[start+i] = input[start+i] ^ test[i]; + } return circshift_prepared_key(prepared_key,l); }