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,21 +290,17 @@ static unsigned char *_base64_decode(const unsigned char *src, size_t len,
|
||||
if (count == 4)
|
||||
{
|
||||
*pos++ = (block[0] << 2) | (block[1] >> 4);
|
||||
*pos++ = (block[1] << 4) | (block[2] >> 2);
|
||||
*pos++ = (block[2] << 6) | block[3];
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (pos > out)
|
||||
{
|
||||
if (in[2] == ch) /* if (in[2] == '=') */
|
||||
{
|
||||
pos -= 2;
|
||||
break;
|
||||
}
|
||||
else if (in[3] == ch) /* else if (in[3] == '=') */
|
||||
*pos++ = (block[1] << 4) | (block[2] >> 2);
|
||||
if (in[3] == ch) /* if (in[3] == '=') */
|
||||
{
|
||||
pos--;
|
||||
break;
|
||||
}
|
||||
*pos++ = (block[2] << 6) | block[3];
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user