diff --git a/libpcp/z85.c b/libpcp/z85.c index d2b2d8b..4292569 100644 --- a/libpcp/z85.c +++ b/libpcp/z85.c @@ -45,7 +45,7 @@ unsigned char *pcp_unpadfour(unsigned char *src, size_t srclen, size_t *dstlen) outlen = srclen; - for(i=srclen; i>0; --i) { + for(i=srclen-1; i>0; --i) { if(src[i] != '\0') { outlen = i + 1; break; @@ -57,50 +57,27 @@ unsigned char *pcp_unpadfour(unsigned char *src, size_t srclen, size_t *dstlen) } unsigned char *pcp_z85_decode(char *z85block, size_t *dstlen) { - unsigned char *bin; - int i, pos; - size_t zlen, binlen, outlen; + unsigned char *bin = NULL; + unsigned char *raw = NULL; + size_t binlen, outlen; - zlen = strlen(z85block); - char *z85 = ucmalloc(zlen+1); - - /* remove newlines */ - pos = 0; - for(i=0; i= 71) { - *z85block++ = '\r'; - *z85block++ = '\n'; - pos = 1; - } - else { - pos++; - } - *z85block++ = z85[i]; - } - */ - char *z = &z85[0]; char *B = &z85block[0]; @@ -150,9 +109,6 @@ char *pcp_z85_encode(unsigned char *raw, size_t srclen, size_t *dstlen) { } *B = '\0'; - /* fprintf(stderr, "z85block len: %d\n", blocklen, strlen(z85block)); */ - /* fprintf(stderr, "z85block: <%s>\n", z85block); */ - *dstlen = blocklen; free(z85); free(padded); diff --git a/src/z85util.c b/src/z85util.c index 799dd5e..96b06d5 100644 --- a/src/z85util.c +++ b/src/z85util.c @@ -129,6 +129,7 @@ int pcpz85_decode(char *infile, char *outfile) { goto errdz3; } + free(encoded); free(decoded); return 0; diff --git a/tests/unittests.cfg b/tests/unittests.cfg index c48d35b..d1c6e75 100644 --- a/tests/unittests.cfg +++ b/tests/unittests.cfg @@ -347,7 +347,7 @@ temporarily disabled prepare = perl -e 'print "X" x 5000; print "\n"' > testfile-toolong cmd = $pcp -V $vault -P -I testfile-toolong - expect = /line is too long/ + expect = /Error: decoded input/ /*