diff options
author | Andreas Schneider <mail@cynapses.org> | 2009-05-05 09:03:07 +0000 |
---|---|---|
committer | Andreas Schneider <mail@cynapses.org> | 2009-05-05 09:03:07 +0000 |
commit | 5708fe172991ae4440e3ab2cb3b4a25f2030410b (patch) | |
tree | 3ee83bb23eec160b7578f3d347b4a6c7ce3c158f | |
parent | cc2df5487a4457078a27d001cc67d911c0511be5 (diff) | |
download | libssh-5708fe172991ae4440e3ab2cb3b4a25f2030410b.tar.gz libssh-5708fe172991ae4440e3ab2cb3b4a25f2030410b.tar.xz libssh-5708fe172991ae4440e3ab2cb3b4a25f2030410b.zip |
Improve _base64_to_bin().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@737 7dcaeef0-15fb-0310-b436-a5af3365683c
-rw-r--r-- | libssh/base64.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/libssh/base64.c b/libssh/base64.c index 7cb2046b..a26c5557 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 */ |