From 5708fe172991ae4440e3ab2cb3b4a25f2030410b Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 5 May 2009 09:03:07 +0000 Subject: Improve _base64_to_bin(). git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@737 7dcaeef0-15fb-0310-b436-a5af3365683c --- libssh/base64.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/libssh/base64.c b/libssh/base64.c index 7cb2046..a26c555 100644 --- a/libssh/base64.c +++ b/libssh/base64.c @@ -200,14 +200,17 @@ static int to_block4(unsigned long *block, const char *source, int num) { } /* num = numbers of final bytes to be decoded */ -static int _base64_to_bin(unsigned char dest[3], char *source,int num){ - unsigned long block; - if(to_block4(&block,source,num)) - return -1; - dest[0]=GET_A(block); - dest[1]=GET_B(block); - dest[2]=GET_C(block); - return 0; +static int _base64_to_bin(unsigned char dest[3], const char *source, int num) { + unsigned long block; + + if (to_block4(&block, source, num) < 0) { + return -1; + } + dest[0] = GET_A(block); + dest[1] = GET_B(block); + dest[2] = GET_C(block); + + return 0; } /* counts the number of "=" signs, and replace them by zeroes */ -- cgit