Fix incorrect assumptions about the size of size_t
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
diff --git a/library/base64.c b/library/base64.c
index 97b4304..ed7db83 100644
--- a/library/base64.c
+++ b/library/base64.c
@@ -82,7 +82,7 @@
*/
static unsigned char mbedtls_base64_eq(size_t in_a, size_t in_b)
{
- uint32_t difference = in_a ^ in_b;
+ size_t difference = in_a ^ in_b;
/* MSVC has a warning about unary minus on unsigned integer types,
* but this is well-defined and precisely what we want to do here. */
@@ -97,7 +97,9 @@
#pragma warning( pop )
#endif
- difference >>= 31;
+ /* cope with the varying size of size_t per platform */
+ difference >>= ( sizeof( difference ) * 8 - 1 );
+
return (unsigned char) ( 1 ^ difference );
}