diff options
| author | Fulton Browne <git@fulton.software> | 2021-05-16 19:21:23 +0000 |
|---|---|---|
| committer | Fulton Browne <git@fulton.software> | 2021-05-16 19:21:23 +0000 |
| commit | a97878bf4502f48a80f5b48ee32752bff7696f71 (patch) | |
| tree | fad44e544a4f1a0c4728bc8416393c82b3d29b7f | |
| parent | 712a87ab8526492284f6dcfe0249d24ea3ffc66f (diff) | |
| download | base64-a97878bf4502f48a80f5b48ee32752bff7696f71.tar.gz | |
| -rw-r--r-- | base64.c | 2 | ||||
| -rw-r--r-- | base64.h | 2 | ||||
| -rw-r--r-- | base64decode.c | 6 |
3 files changed, 5 insertions, 5 deletions
@@ -86,7 +86,7 @@ b64_encode(char* in, unsigned int in_len, char* out){ return k; } -unsigned int +int b64_decode(char* in, unsigned int in_len, char* out){ unsigned int i=0, j=0, k=0, s[4]; @@ -30,4 +30,4 @@ unsigned int b64_encode(char* in, unsigned int in_len, char* out); // in_len : number of bytes to be decoded. // out : pointer to buffer with enough memory, user is responsible for memory allocation, receives "raw" binary // returns size of output excluding null byte -unsigned int b64_decode(char* in, unsigned int in_len, char* out); +int b64_decode(char* in, unsigned int in_len, char* out); diff --git a/base64decode.c b/base64decode.c index 625f08f..3e30fb8 100644 --- a/base64decode.c +++ b/base64decode.c @@ -12,7 +12,7 @@ usage(void) static void decode(int fd, char *name) { - int n; + int n, nb; long tot; char *buf, *outbuf; outbuf = nil; @@ -29,9 +29,9 @@ decode(int fd, char *name) tot += n; } buf[tot] = 0; - print("DEBUG: %d \n", strlen(outbuf)); outbuf = malloc(b64d_size(strlen(buf))); - b64_decode(buf, strlen(buf), outbuf); + nb = b64_decode(buf, strlen(buf), outbuf); + outbuf[nb] = 0; if((n=write(1, outbuf, strlen(outbuf))) != strlen(outbuf)) sysfatal("writing bytes failed"); } |