]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: unix: properly check for octal digits in the "mode" argument
authorWilly Tarreau <w@1wt.eu>
Wed, 4 Oct 2017 12:43:44 +0000 (14:43 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 4 Oct 2017 12:43:44 +0000 (14:43 +0200)
A config containing "stats socket /path/to/socket mode admin" used to
silently start and be unusable (mode 0, level user) because the "mode"
parser doesn't take care of non-digits. Now it properly reports :

   [ALERT] 276/144303 (7019) : parsing [ext-check.cfg:4] : 'stats socket' : ''mode' : missing or invalid mode 'admin' (octal integer expected)'

This can probably be backported to 1.7, 1.6 and 1.5, though reporting
parsing errors in very old versions probably isn't a good idea if the
feature was left unused for years.

src/proto_uxst.c

index 80237b1b4f8ad343d63daad1f2b3af8bab01f83d..80ba8cceb071f96f6d1ac2453b33dc8c6b9d7401 100644 (file)
@@ -623,12 +623,15 @@ static int uxst_unbind_listeners(struct protocol *proto)
 /* parse the "mode" bind keyword */
 static int bind_parse_mode(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
 {
-       if (!*args[cur_arg + 1]) {
-               memprintf(err, "'%s' : missing mode (octal integer expected)", args[cur_arg]);
+       char *endptr;
+
+       conf->ux.mode = strtol(args[cur_arg + 1], &endptr, 8);
+
+       if (!*args[cur_arg + 1] || *endptr) {
+               memprintf(err, "'%s' : missing or invalid mode '%s' (octal integer expected)", args[cur_arg], args[cur_arg + 1]);
                return ERR_ALERT | ERR_FATAL;
        }
 
-       conf->ux.mode = strtol(args[cur_arg + 1], NULL, 8);
        return 0;
 }