]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: cfgparse: move ssl-dh-param-file parsing to ssl_sock
authorWilly Tarreau <w@1wt.eu>
Wed, 21 Dec 2016 22:28:13 +0000 (23:28 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 21 Dec 2016 22:39:26 +0000 (23:39 +0100)
This one was missing an arg count check which was added in the operation.

src/cfgparse.c
src/ssl_sock.c

index 24bccd29f9568b99270f18d0d2b1b3e5a3eb16a1..3ed2c2221dcda77478df37a76c8d8b7ed0982b7d 100644 (file)
@@ -1105,22 +1105,6 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
                }
 #endif /* SYSTEM_MAXCONN */
        }
-#ifdef USE_OPENSSL
-#ifndef OPENSSL_NO_DH
-       else if (!strcmp(args[0], "ssl-dh-param-file")) {
-               if (*(args[1]) == 0) {
-                       Alert("parsing [%s:%d] : '%s' expects a file path as an argument.\n", file, linenum, args[0]);
-                       err_code |= ERR_ALERT | ERR_FATAL;
-                       goto out;
-               }
-               if (ssl_sock_load_global_dh_param_from_file(args[1])) {
-                       Alert("parsing [%s:%d] : '%s': unable to load DH parameters from file <%s>.\n", file, linenum, args[0], args[1]);
-                       err_code |= ERR_ALERT | ERR_FATAL;
-                       goto out;
-               }
-       }
-#endif
-#endif
        else if (!strcmp(args[0], "ssl-server-verify")) {
                if (alertif_too_many_args(1, file, linenum, args, &err_code))
                        goto out;
index 0ac73159b12e0f35c5e553cb56fd86a8e6290829..06d7cabf899356e8d853a5a71dba5ee278df21b5 100644 (file)
@@ -6112,6 +6112,28 @@ static int ssl_parse_global_lifetime(char **args, int section_type, struct proxy
 }
 
 #ifndef OPENSSL_NO_DH
+/* parse "ssl-dh-param-file".
+ * Returns <0 on alert, >0 on warning, 0 on success.
+ */
+static int ssl_parse_global_dh_param_file(char **args, int section_type, struct proxy *curpx,
+                                       struct proxy *defpx, const char *file, int line,
+                                       char **err)
+{
+       if (too_many_args(1, args, err, NULL))
+               return -1;
+
+       if (*(args[1]) == 0) {
+               memprintf(err, "'%s' expects a file path as an argument.", args[0]);
+               return -1;
+       }
+
+       if (ssl_sock_load_global_dh_param_from_file(args[1])) {
+               memprintf(err, "'%s': unable to load DH parameters from file <%s>.", args[0], args[1]);
+               return -1;
+       }
+       return 0;
+}
+
 /* parse "ssl.default-dh-param".
  * Returns <0 on alert, >0 on warning, 0 on success.
  */
@@ -6539,6 +6561,9 @@ static struct cfg_kw_list cfg_kws = {ILH, {
        { CFG_GLOBAL, "maxsslconn", ssl_parse_global_int },
        { CFG_GLOBAL, "ssl-default-bind-options", ssl_parse_default_bind_options },
        { CFG_GLOBAL, "ssl-default-server-options", ssl_parse_default_server_options },
+#ifndef OPENSSL_NO_DH
+       { CFG_GLOBAL, "ssl-dh-param-file", ssl_parse_global_dh_param_file },
+#endif
        { CFG_GLOBAL, "tune.ssl.cachesize", ssl_parse_global_int },
 #ifndef OPENSSL_NO_DH
        { CFG_GLOBAL, "tune.ssl.default-dh-param", ssl_parse_global_default_dh },