mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 20:00:58 +01:00
sanitized pcp_unpadfour(), just return the number of zero padding, leave the input pointer untouched; fixed header
This commit is contained in:
@@ -30,10 +30,10 @@
|
|||||||
|
|
||||||
/* convert a binary stream to one which gets accepted by zmq_z85_encode */
|
/* convert a binary stream to one which gets accepted by zmq_z85_encode */
|
||||||
/* we pad it with zeroes and put the number of zerores in front of it */
|
/* we pad it with zeroes and put the number of zerores in front of it */
|
||||||
unsigned char *pcp_unpadfour(unsigned char *src, size_t srclen, size_t *dstlen);
|
unsigned char *pcp_padfour(unsigned char *src, size_t srclen, size_t *dstlen);
|
||||||
|
|
||||||
/* the reverse of the above */
|
/* the reverse of the above */
|
||||||
unsigned char *pcp_unpadfour(unsigned char *src, size_t srclen, size_t *dstlen);
|
size_t pcp_unpadfour(unsigned char *src, size_t srclen);
|
||||||
|
|
||||||
/* wrapper around zmq Z85 encoding function */
|
/* wrapper around zmq Z85 encoding function */
|
||||||
unsigned char *pcp_z85_decode(char *z85block, size_t *dstlen);
|
unsigned char *pcp_z85_decode(char *z85block, size_t *dstlen);
|
||||||
|
|||||||
10
libpcp/z85.c
10
libpcp/z85.c
@@ -39,7 +39,7 @@ unsigned char *pcp_padfour(unsigned char *src, size_t srclen, size_t *dstlen) {
|
|||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *pcp_unpadfour(unsigned char *src, size_t srclen, size_t *dstlen) {
|
size_t pcp_unpadfour(unsigned char *src, size_t srclen) {
|
||||||
size_t outlen;
|
size_t outlen;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@@ -52,13 +52,11 @@ unsigned char *pcp_unpadfour(unsigned char *src, size_t srclen, size_t *dstlen)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*dstlen = outlen;
|
return outlen;
|
||||||
return src;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *pcp_z85_decode(char *z85block, size_t *dstlen) {
|
unsigned char *pcp_z85_decode(char *z85block, size_t *dstlen) {
|
||||||
unsigned char *bin = NULL;
|
unsigned char *bin = NULL;
|
||||||
unsigned char *raw = NULL;
|
|
||||||
size_t binlen, outlen;
|
size_t binlen, outlen;
|
||||||
|
|
||||||
binlen = strlen(z85block) * 4 / 5;
|
binlen = strlen(z85block) * 4 / 5;
|
||||||
@@ -69,11 +67,11 @@ unsigned char *pcp_z85_decode(char *z85block, size_t *dstlen) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
raw = pcp_unpadfour(bin, binlen, &outlen);
|
outlen = pcp_unpadfour(bin, binlen);
|
||||||
|
|
||||||
*dstlen = outlen;
|
*dstlen = outlen;
|
||||||
|
|
||||||
return raw;
|
return bin;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *pcp_z85_encode(unsigned char *raw, size_t srclen, size_t *dstlen) {
|
char *pcp_z85_encode(unsigned char *raw, size_t srclen, size_t *dstlen) {
|
||||||
|
|||||||
Reference in New Issue
Block a user