check the return value of snprintf
parent
e7b2874e2a
commit
0a87130ee0
|
|
@ -50,6 +50,10 @@ void base64_set_line_separator(struct base64_context *context, \
|
||||||
{
|
{
|
||||||
context->line_sep_len = snprintf(context->line_separator, \
|
context->line_sep_len = snprintf(context->line_separator, \
|
||||||
sizeof(context->line_separator), "%s", pLineSeparator);
|
sizeof(context->line_separator), "%s", pLineSeparator);
|
||||||
|
if (context->line_sep_len >= sizeof(context->line_separator))
|
||||||
|
{
|
||||||
|
context->line_sep_len = sizeof(context->line_separator) - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void base64_init_ex(struct base64_context *context, const int nLineLength, \
|
void base64_init_ex(struct base64_context *context, const int nLineLength, \
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,14 @@ int get_url_content_ex(const char *url, const int url_len,
|
||||||
alloc_size = *content_len - 1;
|
alloc_size = *content_len - 1;
|
||||||
}
|
}
|
||||||
*content_len = 0;
|
*content_len = 0;
|
||||||
|
if (url_len > sizeof(out_buff) - 128)
|
||||||
|
{
|
||||||
|
sprintf(error_info, "file: "__FILE__", line: %d, "
|
||||||
|
"url too long, url length: %d > %d", __LINE__,
|
||||||
|
url_len, (int)(sizeof(out_buff) - 128));
|
||||||
|
|
||||||
|
return ENAMETOOLONG;
|
||||||
|
}
|
||||||
|
|
||||||
if (url_len <= 7 || strncasecmp(url, "http://", 7) != 0)
|
if (url_len <= 7 || strncasecmp(url, "http://", 7) != 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue