]> err.no Git - varnish/commitdiff
Bail if there are multiple .host or .port fields in one backend host.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 22 Jan 2008 08:32:23 +0000 (08:32 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 22 Jan 2008 08:32:23 +0000 (08:32 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2360 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/lib/libvcl/vcc_backend.c

index fdac3593c175cfe486c5fff49a80da1801c47d66..0a8f7afeef42744d78c7873eb7ee9b8dae4f51bd 100644 (file)
@@ -108,8 +108,8 @@ vcc_ParseBackendHost(struct tokenlist *tl, int *nbh)
 {
        struct token *t_field;
        struct token *t_first;
-       struct token *t_host = NULL;
-       struct token *t_port = NULL;
+       struct token *t_host = NULL, *t_fhost = NULL;
+       struct token *t_port = NULL, *t_fport = NULL;
        const char *ep;
 
        t_first = tl->t;
@@ -150,11 +150,33 @@ vcc_ParseBackendHost(struct tokenlist *tl, int *nbh)
                if (vcc_IdIs(t_field, "host")) {
                        ExpectErr(tl, CSTR);
                        assert(tl->t->dec != NULL);
+                       if (t_host != NULL) {
+                               vsb_printf(tl->sb,
+                                   "Multiple .host fields in backend: ");
+                               vcc_ErrToken(tl, t_field);
+                               vsb_printf(tl->sb, " at\n");
+                               vcc_ErrWhere(tl, t_fhost);
+                               vsb_printf(tl->sb, " and\n");
+                               vcc_ErrWhere(tl, t_field);
+                               return;
+                       }
+                       t_fhost = t_field;
                        t_host = tl->t;
                        vcc_NextToken(tl);
                } else if (vcc_IdIs(t_field, "port")) {
                        ExpectErr(tl, CSTR);
                        assert(tl->t->dec != NULL);
+                       if (t_port != NULL) {
+                               vsb_printf(tl->sb,
+                                   "Multiple .port fields in backend: ");
+                               vcc_ErrToken(tl, t_field);
+                               vsb_printf(tl->sb, " at\n");
+                               vcc_ErrWhere(tl, t_fport);
+                               vsb_printf(tl->sb, " and\n");
+                               vcc_ErrWhere(tl, t_field);
+                               return;
+                       }
+                       t_fport = t_field;
                        t_port = tl->t;
                        vcc_NextToken(tl);
                } else {