aboutsummaryrefslogtreecommitdiff
path: root/src/base64.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2019-10-31 16:30:17 +0100
committerAndreas Schneider <asn@cryptomilk.org>2019-12-09 16:08:03 +0100
commitb5160ce9e0cf44033bd7dd66bd1e3802651fc341 (patch)
tree244755a6c4040f54c8fdeb829d5572b8be729104 /src/base64.c
parentfdb7cb8f17dbcb6aa8b56733121da5e9e9ac9850 (diff)
downloadlibssh-b5160ce9e0cf44033bd7dd66bd1e3802651fc341.tar.gz
libssh-b5160ce9e0cf44033bd7dd66bd1e3802651fc341.tar.xz
libssh-b5160ce9e0cf44033bd7dd66bd1e3802651fc341.zip
base64: Reformat bin_to_base64()
Fixes T188 Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'src/base64.c')
-rw-r--r--src/base64.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/base64.c b/src/base64.c
index 21ffb144..f019ef76 100644
--- a/src/base64.c
+++ b/src/base64.c
@@ -270,25 +270,26 @@ static void _bin_to_base64(uint8_t *dest,
*
* @returns the converted string
*/
-unsigned char *bin_to_base64(const unsigned char *source, int len) {
- unsigned char *base64;
- unsigned char *ptr;
- int flen = len + (3 - (len % 3)); /* round to upper 3 multiple */
- flen = (4 * flen) / 3 + 1;
-
- base64 = malloc(flen);
- if (base64 == NULL) {
- return NULL;
- }
- ptr = base64;
+unsigned char *bin_to_base64(const unsigned char *source, int len)
+{
+ unsigned char *base64;
+ unsigned char *ptr;
+ int flen = len + (3 - (len % 3)); /* round to upper 3 multiple */
+ flen = (4 * flen) / 3 + 1;
+
+ base64 = malloc(flen);
+ if (base64 == NULL) {
+ return NULL;
+ }
+ ptr = base64;
- while(len > 0){
- _bin_to_base64(ptr, source, len > 3 ? 3 : len);
- ptr += 4;
- source += 3;
- len -= 3;
- }
- ptr[0] = '\0';
+ while(len > 0){
+ _bin_to_base64(ptr, source, len > 3 ? 3 : len);
+ ptr += 4;
+ source += 3;
+ len -= 3;
+ }
+ ptr[0] = '\0';
- return base64;
+ return base64;
}