mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-05-16 22:58:02 +00:00
BUILD: ssl: NAME_MAX is not portable, use MAXPATHLEN instead
At least Solaris doesn't know about NAME_MAX, so let's use the more portable MAXPATHLEN instead. This issue was reported by Benjamin Polidore.
This commit is contained in:
parent
7896d5293d
commit
ee2663b1cd
@ -437,8 +437,8 @@ int ssl_sock_load_cert(char *path, struct bind_conf *bind_conf, struct proxy *cu
|
|||||||
struct dirent *de;
|
struct dirent *de;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
int pathlen = 0;
|
char *end;
|
||||||
char *end, *fp;
|
char fp[MAXPATHLEN+1];
|
||||||
int cfgerr = 0;
|
int cfgerr = 0;
|
||||||
|
|
||||||
if (!(dir = opendir(path)))
|
if (!(dir = opendir(path)))
|
||||||
@ -448,12 +448,8 @@ int ssl_sock_load_cert(char *path, struct bind_conf *bind_conf, struct proxy *cu
|
|||||||
for (end = path + strlen(path) - 1; end >= path && *end == '/'; end--)
|
for (end = path + strlen(path) - 1; end >= path && *end == '/'; end--)
|
||||||
*end = 0;
|
*end = 0;
|
||||||
|
|
||||||
if (end >= path)
|
|
||||||
pathlen = end + 1 - path;
|
|
||||||
fp = malloc(pathlen + 1 + NAME_MAX + 1);
|
|
||||||
|
|
||||||
while ((de = readdir(dir))) {
|
while ((de = readdir(dir))) {
|
||||||
snprintf(fp, pathlen + 1 + NAME_MAX + 1, "%s/%s", path, de->d_name);
|
snprintf(fp, sizeof(fp), "%s/%s", path, de->d_name);
|
||||||
if (stat(fp, &buf) != 0) {
|
if (stat(fp, &buf) != 0) {
|
||||||
memprintf(err, "%sunable to stat SSL certificate from file '%s' : %s.\n",
|
memprintf(err, "%sunable to stat SSL certificate from file '%s' : %s.\n",
|
||||||
err && *err ? *err : "", fp, strerror(errno));
|
err && *err ? *err : "", fp, strerror(errno));
|
||||||
@ -464,7 +460,6 @@ int ssl_sock_load_cert(char *path, struct bind_conf *bind_conf, struct proxy *cu
|
|||||||
continue;
|
continue;
|
||||||
cfgerr += ssl_sock_load_cert_file(fp, bind_conf, curproxy, err);
|
cfgerr += ssl_sock_load_cert_file(fp, bind_conf, curproxy, err);
|
||||||
}
|
}
|
||||||
free(fp);
|
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
return cfgerr;
|
return cfgerr;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user