aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cgi.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2013-06-05 02:00:26 +0000
committerIngo Schwarze <schwarze@openbsd.org>2013-06-05 02:00:26 +0000
commit8400486b39e9f57a03d2efe49cf8eab233476669 (patch)
tree05031258c9f3babdf621263c0a55031f2a2a2c0a /cgi.c
parent91ed0105333c4ac483f7581f13a317c5560bdf58 (diff)
downloadmandoc-8400486b39e9f57a03d2efe49cf8eab233476669.tar.gz
mandoc-8400486b39e9f57a03d2efe49cf8eab233476669.tar.zst
mandoc-8400486b39e9f57a03d2efe49cf8eab233476669.zip
Some places used PATH_MAX from <limits.h>, some MAXPATHLEN from <sys/param.h>.
Consistently use the PATH_MAX since it is specified by POSIX, while MAXPATHLEN is not. In preparation for using this at a few more places.
Diffstat (limited to 'cgi.c')
-rw-r--r--cgi.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/cgi.c b/cgi.c
index 6b885976..6d40fcde 100644
--- a/cgi.c
+++ b/cgi.c
@@ -1,4 +1,4 @@
-/* $Id: cgi.c,v 1.44 2012/05/27 17:48:57 schwarze Exp $ */
+/* $Id: cgi.c,v 1.45 2013/06/05 02:00:26 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -18,7 +18,6 @@
#include "config.h"
#endif
-#include <sys/param.h>
#include <sys/wait.h>
#include <assert.h>
@@ -726,7 +725,7 @@ format(const struct req *req, const char *file)
struct man *man;
void *vp;
enum mandoclevel rc;
- char opts[MAXPATHLEN + 128];
+ char opts[PATH_MAX + 128];
if (-1 == (fd = open(file, O_RDONLY, 0))) {
resp_baddb();
@@ -777,7 +776,7 @@ pg_show(const struct req *req, char *path)
struct manpaths ps;
size_t sz;
char *sub;
- char file[MAXPATHLEN];
+ char file[PATH_MAX];
const char *cp;
int rc, catm;
unsigned int vol, rec, mr;
@@ -831,10 +830,10 @@ pg_show(const struct req *req, char *path)
goto out;
}
- sz = strlcpy(file, ps.paths[vol], MAXPATHLEN);
- assert(sz < MAXPATHLEN);
- strlcat(file, "/", MAXPATHLEN);
- strlcat(file, MANDOC_IDX, MAXPATHLEN);
+ sz = strlcpy(file, ps.paths[vol], PATH_MAX);
+ assert(sz < PATH_MAX);
+ strlcat(file, "/", PATH_MAX);
+ strlcat(file, MANDOC_IDX, PATH_MAX);
/* Open the index recno(3) database. */
@@ -863,8 +862,8 @@ pg_show(const struct req *req, char *path)
resp_baddb();
else {
file[(int)sz] = '\0';
- strlcat(file, "/", MAXPATHLEN);
- strlcat(file, cp, MAXPATHLEN);
+ strlcat(file, "/", PATH_MAX);
+ strlcat(file, cp, PATH_MAX);
if (catm)
catman(req, file);
else
@@ -973,7 +972,7 @@ int
main(void)
{
int i;
- char buf[MAXPATHLEN];
+ char buf[PATH_MAX];
DIR *cwd;
struct req req;
char *p, *path, *subpath;
@@ -1010,7 +1009,7 @@ main(void)
memset(&req, 0, sizeof(struct req));
- strlcpy(buf, ".", MAXPATHLEN);
+ strlcpy(buf, ".", PATH_MAX);
pathgen(cwd, buf, &req);
closedir(cwd);
@@ -1120,8 +1119,8 @@ pathgen(DIR *dir, char *path, struct req *req)
int rc;
size_t sz, ssz;
- sz = strlcat(path, "/", MAXPATHLEN);
- if (sz >= MAXPATHLEN) {
+ sz = strlcat(path, "/", PATH_MAX);
+ if (sz >= PATH_MAX) {
fprintf(stderr, "%s: Path too long", path);
return;
}
@@ -1138,9 +1137,9 @@ pathgen(DIR *dir, char *path, struct req *req)
continue;
path[(int)sz] = '\0';
- ssz = strlcat(path, d->d_name, MAXPATHLEN);
+ ssz = strlcat(path, d->d_name, PATH_MAX);
- if (ssz >= MAXPATHLEN) {
+ if (ssz >= PATH_MAX) {
fprintf(stderr, "%s: Path too long", path);
return;
} else if (NULL == (cd = opendir(path))) {
@@ -1187,9 +1186,9 @@ pathgen(DIR *dir, char *path, struct req *req)
continue;
path[(int)sz] = '\0';
- ssz = strlcat(path, d->d_name, MAXPATHLEN);
+ ssz = strlcat(path, d->d_name, PATH_MAX);
- if (ssz >= MAXPATHLEN) {
+ if (ssz >= PATH_MAX) {
fprintf(stderr, "%s: Path too long", path);
return;
} else if (NULL == (cd = opendir(path))) {