[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] branch master updated: tlsauthentication.c: better fix f
From: |
gnunet |
Subject: |
[libmicrohttpd] branch master updated: tlsauthentication.c: better fix for compiler warning |
Date: |
Wed, 25 Aug 2021 19:27:02 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
The following commit(s) were added to refs/heads/master by this push:
new 0497e9c8 tlsauthentication.c: better fix for compiler warning
0497e9c8 is described below
commit 0497e9c801754079920412b4d92733eae7984daf
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Wed Aug 25 20:22:57 2021 +0300
tlsauthentication.c: better fix for compiler warning
---
doc/examples/tlsauthentication.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/doc/examples/tlsauthentication.c b/doc/examples/tlsauthentication.c
index d7ddbd43..b31eab43 100644
--- a/doc/examples/tlsauthentication.c
+++ b/doc/examples/tlsauthentication.c
@@ -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;
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libmicrohttpd] branch master updated: tlsauthentication.c: better fix for compiler warning,
gnunet <=