diff --git a/cryptlib.cpp b/cryptlib.cpp index f65123ab..fdcbf1bf 100644 --- a/cryptlib.cpp +++ b/cryptlib.cpp @@ -764,22 +764,15 @@ size_t BufferedTransformation::PutWord64(word64 value, ByteOrder order, bool blo return ChannelPutWord64(DEFAULT_CHANNEL, value, order, blocking); } -// Issue 340 -#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wconversion" -# pragma GCC diagnostic ignored "-Wsign-conversion" -#endif - size_t BufferedTransformation::PeekWord16(word16 &value, ByteOrder order) const { byte buf[2] = {0, 0}; size_t len = Peek(buf, 2); if (order == BIG_ENDIAN_ORDER) - value = (buf[0] << 8) | buf[1]; + value = ((word16)buf[0] << 8) | (word16)buf[1]; else - value = (buf[1] << 8) | buf[0]; + value = ((word16)buf[1] << 8) | (word16)buf[0]; return len; } @@ -790,9 +783,11 @@ size_t BufferedTransformation::PeekWord32(word32 &value, ByteOrder order) const size_t len = Peek(buf, 4); if (order == BIG_ENDIAN_ORDER) - value = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf [3]; + value = ((word32)buf[0] << 24) | ((word32)buf[1] << 16) | + ((word32)buf[2] << 8) | (word32)buf[3]; else - value = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf [0]; + value = ((word32)buf[3] << 24) | ((word32)buf[2] << 16) | + ((word32)buf[1] << 8) | (word32)buf[0]; return len; } @@ -814,11 +809,6 @@ size_t BufferedTransformation::PeekWord64(word64 &value, ByteOrder order) const return len; } -// Issue 340 -#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE -# pragma GCC diagnostic pop -#endif - size_t BufferedTransformation::GetWord16(word16 &value, ByteOrder order) { return (size_t)Skip(PeekWord16(value, order)); diff --git a/cryptlib.h b/cryptlib.h index 375b46ab..1cb753ac 100644 --- a/cryptlib.h +++ b/cryptlib.h @@ -2306,7 +2306,10 @@ protected: {return propagation != 0 ? propagation - 1 : 0;} private: - byte m_buf[4]; // for ChannelPutWord16 and ChannelPutWord32, to ensure buffer isn't deallocated before non-blocking operation completes + // for ChannelPutWord16, ChannelPutWord32 and ChannelPutWord64, + // to ensure the buffer isn't deallocated before non-blocking + // operation completes + byte m_buf[8]; }; /// \brief An input discarding BufferedTransformation