Skip to content

Commit

Permalink
libc/base64: check buffer overflow for last char
Browse files Browse the repository at this point in the history
Signed-off-by: Xu Xingliang <[email protected]>
  • Loading branch information
XuNeo authored and xiaoxiang781216 committed Oct 8, 2024
1 parent 4ed506d commit b75412d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libs/libc/net/lib_base64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit b75412d

Please sign in to comment.