You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-dev@httpd.apache.org by Max Kellermann <ma...@linuxtag.org> on 2003/12/11 12:30:09 UTC
Bugreport: Segmentation fault when using wrong percent escapes
Hi,
I found a bug in apreq2 v2.02-dev (which is still in CVS HEAD): when
you decode a query string which uses an invalid percent escape
(e.g. "test=foo%d"), apreq segfaults in function apr_table_addn.
This is because apreq_decode_param leaves param->v.name with a NULL
value when it finds an invalid sequence. It also sets param->v.status
to APR_BADARG. Calling function apreq_parse_query_string does not
check param->v.status and tries to call apr_table_addn with NULL key.
The following patch fixes this bug:
--- apreq_params.c (revision 62)
+++ apreq_params.c (working copy)
@@ -276,7 +276,7 @@
param = apreq_decode_param(pool, start, nlen, vlen);
- if (param)
+ if (param && param->v.status == APR_SUCCESS)
apr_table_addn(t, param->v.name, param->v.data);
else
return APR_BADARG;
(you might prefer to return param->v.status on error....)
Regards,
Max Kellermann
Re: Bugreport: Segmentation fault when using wrong percent escapes
Posted by Joe Schaefer <jo...@sunstarsys.com>.
Max Kellermann <ma...@linuxtag.org> writes:
> Hi,
>
> I found a bug in apreq2 v2.02-dev (which is still in CVS HEAD): when
> you decode a query string which uses an invalid percent escape
> (e.g. "test=foo%d"), apreq segfaults in function apr_table_addn.
>
> This is because apreq_decode_param leaves param->v.name with a NULL
> value when it finds an invalid sequence. It also sets param->v.status
> to APR_BADARG. Calling function apreq_parse_query_string does not
> check param->v.status and tries to call apr_table_addn with NULL key.
Thanks! I just applied a minor variant of your patch.
--
Joe Schaefer