Fix NULL ptr reference for HTTP proxy.
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 19 Mar 2009 12:32:13 +0000 (13:32 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 19 Mar 2009 12:32:54 +0000 (13:32 +0100)
The ser->host might be 0 in case attribute 'host' is not given for element
'listen' in configuration. This commit avoids referencing it in sprintf.

src/http.c

index 86f8dc2..62233b2 100644 (file)
@@ -794,7 +794,8 @@ static int http_proxy(struct http_request *rq)
         hp = http_header_append(c, hp, 
                                 "X-Pazpar2-Server-Port", server_port);
         sprintf(server_via,  "1.1 %s:%s (%s/%s)",  
-                ser->host, server_port, PACKAGE_NAME, PACKAGE_VERSION);
+                ser->host ? ser->host : "@",
+                server_port, PACKAGE_NAME, PACKAGE_VERSION);
         hp = http_header_append(c, hp, "Via" , server_via);
         hp = http_header_append(c, hp, "X-Forwarded-For", c->addr);
     }