diff --git a/doc/examples/tlsauthentication.c b/doc/examples/tlsauthentication.c index 5b2dec1d..d7ddbd43 100644 --- a/doc/examples/tlsauthentication.c +++ b/doc/examples/tlsauthentication.c @@ -53,8 +53,10 @@ string_to_base64 (const char *message) strncat (tmp, &lookup[l & 0x3F], 1); } - if (length % 3) - strncat (tmp, "==", 3 - length % 3); + if (2 == length % 3) + strncat (tmp, "=", 1); + else if (1 == length % 3) + strncat (tmp, "==", 2); return tmp; }