diff --git a/base64.c b/base64.c
index 253bf4e..efcf3d4 100644
--- a/base64.c
+++ b/base64.c
@@ -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];
diff --git a/base64.h b/base64.h
index 7f7e319..d5d05be 100644
--- a/base64.h
+++ b/base64.h
@@ -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");
}
|