Merged in AVyhovanec/apps (pull request #158)
"dst" overflow protection when base64 string ends with "=" Approved-by: GregoryN <gnutt@nuttx.org>
This commit is contained in:
parent
0989023de7
commit
9aa2f5c5a2
@ -290,24 +290,20 @@ static unsigned char *_base64_decode(const unsigned char *src, size_t len,
|
||||
if (count == 4)
|
||||
{
|
||||
*pos++ = (block[0] << 2) | (block[1] >> 4);
|
||||
if (in[2] == ch) /* if (in[2] == '=') */
|
||||
{
|
||||
break;
|
||||
}
|
||||
*pos++ = (block[1] << 4) | (block[2] >> 2);
|
||||
if (in[3] == ch) /* if (in[3] == '=') */
|
||||
{
|
||||
break;
|
||||
}
|
||||
*pos++ = (block[2] << 6) | block[3];
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos > out)
|
||||
{
|
||||
if (in[2] == ch) /* if (in[2] == '=') */
|
||||
{
|
||||
pos -= 2;
|
||||
}
|
||||
else if (in[3] == ch) /* else if (in[3] == '=') */
|
||||
{
|
||||
pos--;
|
||||
}
|
||||
}
|
||||
|
||||
*out_len = pos - out;
|
||||
return out;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user