mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 13:18:50 +08:00
libc/base64: check buffer overflow for last char
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
This commit is contained in:
parent
4ed506d6ab
commit
b75412d96a
1 changed files with 6 additions and 1 deletions
|
@ -83,7 +83,12 @@ int b64_ntop(FAR const unsigned char *src, size_t srclen,
|
|||
*target++ = g_pad64;
|
||||
}
|
||||
|
||||
*target = '\0';
|
||||
if (datalen >= targsize)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
*target = '\0'; /* Returned length doesn't include '\0' */
|
||||
return datalen;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue