diff --git a/src/cfgparse-ssl.c b/src/cfgparse-ssl.c index 7acd135dd..462743e45 100644 --- a/src/cfgparse-ssl.c +++ b/src/cfgparse-ssl.c @@ -659,11 +659,11 @@ static int bind_parse_crt(char **args, int cur_arg, struct proxy *px, struct bin } if ((*args[cur_arg + 1] != '/' ) && global_ssl.crt_base) { - if ((strlen(global_ssl.crt_base) + 1 + strlen(args[cur_arg + 1]) + 1) > MAXPATHLEN) { + if ((strlen(global_ssl.crt_base) + 1 + strlen(args[cur_arg + 1]) + 1) > sizeof(path) || + snprintf(path, sizeof(path), "%s/%s", global_ssl.crt_base, args[cur_arg + 1]) > sizeof(path)) { memprintf(err, "'%s' : path too long", args[cur_arg]); return ERR_ALERT | ERR_FATAL; } - snprintf(path, sizeof(path), "%s/%s", global_ssl.crt_base, args[cur_arg + 1]); return ssl_sock_load_cert(path, conf, err); } diff --git a/src/ssl_crtlist.c b/src/ssl_crtlist.c index 1615ac51d..f43982f4d 100644 --- a/src/ssl_crtlist.c +++ b/src/ssl_crtlist.c @@ -536,13 +536,13 @@ int crtlist_parse_file(char *file, struct bind_conf *bind_conf, struct proxy *cu } if (*crt_path != '/' && global_ssl.crt_base) { - if ((strlen(global_ssl.crt_base) + 1 + strlen(crt_path)) > MAXPATHLEN) { + if ((strlen(global_ssl.crt_base) + 1 + strlen(crt_path)) > sizeof(path) || + snprintf(path, sizeof(path), "%s/%s", global_ssl.crt_base, crt_path)) { memprintf(err, "parsing [%s:%d]: '%s' : path too long", file, linenum, crt_path); cfgerr |= ERR_ALERT | ERR_FATAL; goto error; } - snprintf(path, sizeof(path), "%s/%s", global_ssl.crt_base, crt_path); crt_path = path; } @@ -1270,12 +1270,12 @@ static int cli_parse_add_crtlist(char **args, char *payload, struct appctx *appc } if (*cert_path != '/' && global_ssl.crt_base) { - if ((strlen(global_ssl.crt_base) + 1 + strlen(cert_path)) > MAXPATHLEN) { + if ((strlen(global_ssl.crt_base) + 1 + strlen(cert_path)) > sizeof(path) || + snprintf(path, sizeof(path), "%s/%s", global_ssl.crt_base, cert_path) > sizeof(path)) { memprintf(&err, "'%s' : path too long", cert_path); cfgerr |= ERR_ALERT | ERR_FATAL; goto error; } - snprintf(path, sizeof(path), "%s/%s", global_ssl.crt_base, cert_path); cert_path = path; }