Ales Krenek - 2009-10-22

Hi there,

I've managed to build the module successfully but when trying to access the calendar over SSL it kept crashing apache here:

<pre>
Program received signal SIGSEGV, Segmentation fault.

0xb70afd4b in caldav_send_multiget (pchSubDir=0x0, depth=1, depth_current=0,
    bb=0xbf90ca0c, r=0x835e710, conf=0x81932b0, subpool=0x8374e38,
    nProp=0x83776e0, p=0x0) at caldav.c:780
780                         if (lookup.rnew->status == HTTP_OK)
</pre>

This is because the preceeding dav_lookup_uri() call failed with null rnew
and the error:

<pre>
(gdb) p lookup
$1 = {rnew = 0x0, err = {status = 502, error_id = 0,
    desc = 0x8374d98 "Destination URI refers to different scheme or port (http://hostname:80)\n(want: https://hostname:443)", save_errno = 0, namespace = 0x0,
    tagname = 0x0, childtags = 0x0, prev = 0x0}}
</pre>

This happens due to hand-crafted unsuitable szUri above.
The following tentative patch fixes the problem for me.
(I'm an avarage hacker rather than apache expert, so treat it as pointing
out the problem rather than a clean solution.)

Regards,

Ales

<pre>
-- caldav.c.orig 2009-10-22 14:22:59.771933670 +0200
+++ caldav.c 2009-10-22 14:50:30.859372298 +0200
@@ -772,8 +772,10 @@
             }
             else {
                 if (uri.path && uri.path == '/') {
-                    char *szUri = apr_pstrcat (subpool, "http://",
+     char port; snprintf(port,100,":%d",r->connection->local_addr->port);
+                    char *szUri = apr_pstrcat (subpool, ap_http_scheme(r), "://",
                                                r->hostname ? r->hostname : "localhost",
+        port,
                                                uri.path,
                                                NULL);
                     lookup = dav_lookup_uri (szUri, r, TRUE);
</pre>