formboundary: convert assert into run-time check

... to really make sure the boundary fits in the target buffer.

Fixes unused parameter 'buflen' warning.

Reported-by: Michael Kaufmann
Bug: https://github.com/curl/curl/pull/1468#issuecomment-300078754
This commit is contained in:
Daniel Stenberg 2017-05-09 09:08:25 +02:00
parent 2f6bfd5499
commit 158d701641
1 changed files with 2 additions and 1 deletions

View File

@ -1557,7 +1557,8 @@ static CURLcode formboundary(struct Curl_easy *data,
{
/* 24 dashes and 16 hexadecimal digits makes 64 bit (18446744073709551615)
combinations */
DEBUGASSERT(buflen >= 41);
if(buflen < 41)
return CURLE_BAD_FUNCTION_ARGUMENT;
memset(buffer, '-', 24);
Curl_rand_hex(data, (unsigned char *)&buffer[24], 17);