check_curl: fixed a potential buffer overflow in retir/uri_string

This commit is contained in:
Andreas Baumann 2021-07-25 18:49:06 +02:00
parent 3f5c54c783
commit de5503063e

View file

@ -1033,8 +1033,8 @@ char*
uri_string (const UriTextRangeA range, char* buf, size_t buflen)
{
if (!range.first) return "(null)";
strncpy (buf, range.first, max (buflen, range.afterLast - range.first));
buf[max (buflen, range.afterLast - range.first)] = '\0';
strncpy (buf, range.first, max (buflen-1, range.afterLast - range.first));
buf[max (buflen-1, range.afterLast - range.first)] = '\0';
buf[range.afterLast - range.first] = '\0';
return buf;
}