Skip to content
Snippets Groups Projects
Commit 83f5e1b3 authored by deuce's avatar deuce
Browse files

Don't read past the end of the input string, even if you're going to ignore

what you see there.
parent 29f1498a
Branches
Tags
No related merge requests found
......@@ -131,22 +131,29 @@ int b64_encode(char *target, size_t tlen, const char *source, size_t slen) {
FREE_AND_NULL(tmpbuf);
return(-1);
}
enc=buf|((*inp & 0xF0) >> 4);
if(inp==inend)
done=1;
if (!done)
enc=buf|((*inp & 0xF0) >> 4);
if(add_char(outp++, enc, done, outend)) {
FREE_AND_NULL(tmpbuf);
return(-1);
}
if(inp==inend)
done=1;
buf=(*(inp++)<<2)&0x3C;
enc=buf|((*inp & 0xC0)>>6);
if (!done) {
buf=(*(inp++)<<2)&0x3C;
if (inp == inend)
enc=buf;
else
enc=buf|((*inp & 0xC0)>>6);
}
if(add_char(outp++, enc, done, outend)) {
FREE_AND_NULL(tmpbuf);
return(-1);
}
if(inp==inend)
done=1;
enc=((int)*(inp++))&0x3F;
if (!done)
enc=((int)*(inp++))&0x3F;
if(add_char(outp++, enc, done, outend)) {
FREE_AND_NULL(tmpbuf);
return(-1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment