mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-25 04:09:31 +03:00
tlsauthentication.c: better fix for compiler warning
This commit is contained in:
@@ -30,13 +30,14 @@ string_to_base64 (const char *message)
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
unsigned long l;
|
||||
size_t i;
|
||||
size_t j;
|
||||
char *tmp;
|
||||
size_t length = strlen (message);
|
||||
|
||||
tmp = malloc (length * 2 + 1);
|
||||
if (NULL == tmp)
|
||||
return NULL;
|
||||
tmp[0] = 0;
|
||||
j = 0;
|
||||
for (i = 0; i < length; i += 3)
|
||||
{
|
||||
l = (((unsigned long) message[i]) << 16)
|
||||
@@ -44,19 +45,21 @@ string_to_base64 (const char *message)
|
||||
| (((i + 2) < length) ? ((unsigned long) message[i + 2]) : 0);
|
||||
|
||||
|
||||
strncat (tmp, &lookup[(l >> 18) & 0x3F], 1);
|
||||
strncat (tmp, &lookup[(l >> 12) & 0x3F], 1);
|
||||
tmp [j++] = lookup[(l >> 18) & 0x3F];
|
||||
tmp [j++] = lookup[(l >> 12) & 0x3F];
|
||||
|
||||
if (i + 1 < length)
|
||||
strncat (tmp, &lookup[(l >> 6) & 0x3F], 1);
|
||||
tmp [j++] = lookup[(l >> 6) & 0x3F];
|
||||
if (i + 2 < length)
|
||||
strncat (tmp, &lookup[l & 0x3F], 1);
|
||||
tmp [j++] = lookup[l & 0x3F];
|
||||
}
|
||||
|
||||
if (2 == length % 3)
|
||||
strncat (tmp, "=", 1);
|
||||
else if (1 == length % 3)
|
||||
strncat (tmp, "==", 2);
|
||||
if (0 != length % 3)
|
||||
tmp [j++] = '=';
|
||||
if (1 == length % 3)
|
||||
tmp [j++] = '=';
|
||||
|
||||
tmp [j] = 0;
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user