]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: cfgparse: reject incorrect 'timeout retry' keyword spelling in resolvers
authorPieter Baauw <piba.nl.dev@gmail.com>
Sat, 13 Feb 2016 14:51:58 +0000 (15:51 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 17 Feb 2016 09:10:06 +0000 (10:10 +0100)
If for example it was written as 'timeout retri 1s' or 'timeout wrong 1s'
this would be used for the retry timeout value. Resolvers section only
timeout setting currently is 'retry', others are still parsed as before
this patch to not break existing configurations.

A less strict version will be backported to 1.6.

src/cfgparse.c

index d44f57a43ff25e4808e53d382ec2db89cf450263..99e97c7de551978ef422a8fef2957c19a3893068 100644 (file)
@@ -2438,23 +2438,37 @@ int cfg_parse_resolvers(const char *file, int linenum, char **args, int kwm)
                curr_resolvers->resolve_retries = atoi(args[1]);
        }
        else if (strcmp(args[0], "timeout") == 0) {
-               const char *res;
-               unsigned int timeout_retry;
-
-               if (!*args[2]) {
+               if (!*args[1]) {
                        Alert("parsing [%s:%d] : '%s' expects 'retry' and <time> as arguments.\n",
                                file, linenum, args[0]);
                        err_code |= ERR_ALERT | ERR_FATAL;
                        goto out;
                }
-               res = parse_time_err(args[2], &timeout_retry, TIME_UNIT_MS);
-               if (res) {
-                       Alert("parsing [%s:%d]: unexpected character '%c' in argument to <%s>.\n",
-                               file, linenum, *res, args[0]);
+               else if (strcmp(args[1], "retry") == 0) {
+                       const char *res;
+                       unsigned int timeout_retry;
+
+                       if (!*args[2]) {
+                               Alert("parsing [%s:%d] : '%s %s' expects <time> as argument.\n",
+                                       file, linenum, args[0], args[1]);
+                               err_code |= ERR_ALERT | ERR_FATAL;
+                               goto out;
+                       }
+                       res = parse_time_err(args[2], &timeout_retry, TIME_UNIT_MS);
+                       if (res) {
+                               Alert("parsing [%s:%d]: unexpected character '%c' in argument to <%s %s>.\n",
+                                       file, linenum, *res, args[0], args[1]);
+                               err_code |= ERR_ALERT | ERR_FATAL;
+                               goto out;
+                       }
+                       curr_resolvers->timeout.retry = timeout_retry;
+               }
+               else {
+                       Alert("parsing [%s:%d] : '%s' expects 'retry' and <time> as arguments got '%s'.\n",
+                               file, linenum, args[0], args[1]);
                        err_code |= ERR_ALERT | ERR_FATAL;
                        goto out;
                }
-               curr_resolvers->timeout.retry = timeout_retry;
        } /* neither "nameserver" nor "resolvers" */
        else if (*args[0] != 0) {
                Alert("parsing [%s:%d] : unknown keyword '%s' in '%s' section\n", file, linenum, args[0], cursection);