mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-25 04:09:31 +03:00
use proper guards to avoid (theoretical) off-by-one in pct decoding
This commit is contained in:
@@ -1773,9 +1773,8 @@ MHD_str_pct_decode_strict_n_ (const char *pct_encoded,
|
||||
const char chr = pct_encoded[r];
|
||||
if ('%' == chr)
|
||||
{
|
||||
if (2 > pct_encoded_len - r)
|
||||
if (3 > pct_encoded_len - r)
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
const char c1 = pct_encoded[++r];
|
||||
const char c2 = pct_encoded[++r];
|
||||
@@ -1805,9 +1804,8 @@ MHD_str_pct_decode_strict_n_ (const char *pct_encoded,
|
||||
return 0;
|
||||
if ('%' == chr)
|
||||
{
|
||||
if (2 > pct_encoded_len - r)
|
||||
if (3 > pct_encoded_len - r)
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
const char c1 = pct_encoded[++r];
|
||||
const char c2 = pct_encoded[++r];
|
||||
@@ -1853,7 +1851,7 @@ MHD_str_pct_decode_lenient_n_ (const char *pct_encoded,
|
||||
const char chr = pct_encoded[r];
|
||||
if ('%' == chr)
|
||||
{
|
||||
if (2 > pct_encoded_len - r)
|
||||
if (3 > pct_encoded_len - r)
|
||||
{
|
||||
if (NULL != broken_encoding)
|
||||
*broken_encoding = true;
|
||||
@@ -1897,7 +1895,7 @@ MHD_str_pct_decode_lenient_n_ (const char *pct_encoded,
|
||||
return 0;
|
||||
if ('%' == chr)
|
||||
{
|
||||
if (2 > pct_encoded_len - r)
|
||||
if (3 > pct_encoded_len - r)
|
||||
{
|
||||
if (NULL != broken_encoding)
|
||||
*broken_encoding = true;
|
||||
|
||||
Reference in New Issue
Block a user