You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-dev@httpd.apache.org by Jacek Prucia <ja...@7bulls.com> on 2002/08/01 19:21:16 UTC

[PATCH] Misformed URLs cause segfault

On Wed, 31 Jul 2002 23:45:33 -0400
Rodent of Unusual Size <Ke...@Golux.Com> wrote:

[...]
>     * Misformed URLs cause a segfault. When we fix this we should
>       make sure to print out a helpful message when this occurs.
>       (This is not something that can be detected with a validating
>       XML parser, unfortunately.)

Here's the patch that fixes this problem. Well... at least the segfault,
because i have no idea how helpful we might be in case of misformed URL.
Right now bogus URL is sent to stderr, but it could be eventually
acompanied by line number in config file (if posible at all). This might
be nice with oversized flood config files :)

Look's like this block of code needs a few more tests. In particular i
think flood only cares about http:// schema, so everything else is
wrong. There could be more checks, but this is all i can come up with
right now. I'll post a patch when i'll have all tests figured out.

One more thing. Right now i'm exiting flood with exit(). This schould be
no problem, since no matter what resources we have allocated, they will
be released. OTOH maybe there is something i'm missing, and it has to be
done other way...

Anyway here's the patch for RBC (Review, Bless, Commit)

regards,
-- 
Jacek Prucia
7bulls.com S.A.
http://www.7bulls.com/


--- flood_round_robin.c.orig	2002-08-01 12:50:15.000000000 +0200
+++ flood_round_robin.c	2002-08-01 18:59:39.000000000 +0200
@@ -788,6 +788,10 @@
     r->parsed_uri = apr_pcalloc(rp->pool, sizeof(apr_uri_t));
 
     apr_uri_parse(rp->pool, r->uri, r->parsed_uri);
+    if (r->parsed_uri->scheme == NULL || r->parsed_uri->hostname ==
NULL) {
+       apr_file_printf (local_stderr, "Misformed URL '%s'\n", r->uri);
+       exit (APR_EGENERAL);
+    }
     if (!r->parsed_uri->port)
     {
         r->parsed_uri->port =