diff --git a/src/base64.c b/src/base64.c index 1ff77bf..1c9bf74 100644 --- a/src/base64.c +++ b/src/base64.c @@ -50,6 +50,10 @@ void base64_set_line_separator(struct base64_context *context, \ { context->line_sep_len = snprintf(context->line_separator, \ 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, \ diff --git a/src/http_func.c b/src/http_func.c index b0f2743..5ea4934 100644 --- a/src/http_func.c +++ b/src/http_func.c @@ -55,6 +55,14 @@ int get_url_content_ex(const char *url, const int url_len, alloc_size = *content_len - 1; } *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) {