mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-25 07:31:27 +00:00
#10 fix offbyone error in decode
This commit is contained in:
parent
7d7a81374e
commit
0e951ef007
|
@ -170,28 +170,31 @@ decode_data(char *dest, int size, const char *src, char *srcend)
|
|||
int padded;
|
||||
char encoded[255];
|
||||
char padding[5];
|
||||
int enclen;
|
||||
char *pp;
|
||||
char *ep;
|
||||
|
||||
memset(encoded, 0, sizeof(encoded));
|
||||
memset(dest, 0, size);
|
||||
|
||||
// The first char is not Base32-encoded, just pass it through
|
||||
/* First byte is not encoded */
|
||||
*dest++ = *src++;
|
||||
len = 1;
|
||||
|
||||
ep = encoded;
|
||||
while(src < srcend) {
|
||||
enclen = 0;
|
||||
while(enclen < sizeof(encoded) && src < srcend) {
|
||||
if(*src == '.') {
|
||||
src++;
|
||||
continue;
|
||||
}
|
||||
|
||||
*ep++ = *src++;
|
||||
enclen++;
|
||||
}
|
||||
chunks = strlen(encoded) / 8;
|
||||
padded = strlen(encoded) % 8;
|
||||
chunks = enclen / 8;
|
||||
padded = enclen % 8;
|
||||
|
||||
len = 0;
|
||||
ep = encoded;
|
||||
for (i = 0; i < chunks-1; i++) {
|
||||
decode_chunk(dest, ep);
|
||||
|
|
Loading…
Reference in a new issue