diff options
-rw-r--r-- | cgi.c | 33 | ||||
-rw-r--r-- | mandocdb.c | 32 | ||||
-rw-r--r-- | manpage.c | 6 | ||||
-rw-r--r-- | manpath.c | 6 | ||||
-rw-r--r-- | mansearch.c | 13 | ||||
-rw-r--r-- | mansearch.h | 2 |
6 files changed, 43 insertions, 49 deletions
@@ -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))) { @@ -19,7 +19,6 @@ #include "config.h" #endif -#include <sys/param.h> #include <sys/stat.h> #include <assert.h> @@ -28,6 +27,7 @@ #include <fcntl.h> #include <fts.h> #include <getopt.h> +#include <limits.h> #include <stddef.h> #include <stdint.h> #include <stdlib.h> @@ -98,7 +98,7 @@ struct of { struct of *next; /* next in ofs */ enum form dform; /* path-cued form */ enum form sform; /* suffix-cued form */ - char file[MAXPATHLEN]; /* filename rel. to manpath */ + char file[PATH_MAX]; /* filename rel. to manpath */ const char *desc; /* parsed description */ const char *sec; /* suffix-cued section (or empty) */ const char *dsec; /* path-cued section (or empty) */ @@ -313,7 +313,7 @@ static const struct mdoc_handler mdocs[MDOC_MAX] = { int main(int argc, char *argv[]) { - char cwd[MAXPATHLEN]; + char cwd[PATH_MAX]; int ch, rc, fd, i; unsigned int index; size_t j, sz; @@ -350,7 +350,7 @@ main(int argc, char *argv[]) * handle relative paths, and by doing this, we can return to * the starting point. */ - if (NULL == getcwd(cwd, MAXPATHLEN)) { + if (NULL == getcwd(cwd, PATH_MAX)) { perror(NULL); return(EXIT_FAILURE); } else if (-1 == (fd = open(cwd, O_RDONLY, 0))) { @@ -876,7 +876,7 @@ ofadd(const char *base, int dform, const char *file, } of = mandoc_calloc(1, sizeof(struct of)); - strlcpy(of->file, file, MAXPATHLEN); + strlcpy(of->file, file, PATH_MAX); of->name = name; of->sec = sec; of->dsec = dsec; @@ -920,7 +920,7 @@ ofmerge(struct mchars *mc, struct mparse *mp, const char *base) size_t sz; struct mdoc *mdoc; struct man *man; - char buf[MAXPATHLEN]; + char buf[PATH_MAX]; char *bufp; const char *msec, *march, *mtitle, *cp; struct of *of; @@ -935,8 +935,8 @@ ofmerge(struct mchars *mc, struct mparse *mp, const char *base) * own. */ if ( ! use_all && FORM_CAT == of->dform) { - sz = strlcpy(buf, of->file, MAXPATHLEN); - if (sz >= MAXPATHLEN) { + sz = strlcpy(buf, of->file, PATH_MAX); + if (sz >= PATH_MAX) { if (warnings) say(base, of->file, "Filename too long"); @@ -947,7 +947,7 @@ ofmerge(struct mchars *mc, struct mparse *mp, const char *base) memcpy(bufp, "man", 3); if (NULL != (bufp = strrchr(buf, '.'))) *++bufp = '\0'; - strlcat(buf, of->dsec, MAXPATHLEN); + strlcat(buf, of->dsec, PATH_MAX); if (filecheck(buf)) { if (warnings) say(base, of->file, "Man " @@ -1875,7 +1875,7 @@ static void dbclose(const char *base, int real) { size_t i; - char file[MAXPATHLEN]; + char file[PATH_MAX]; if (nodb) return; @@ -1891,8 +1891,8 @@ dbclose(const char *base, int real) if (real) return; - strlcpy(file, MANDOC_DB, MAXPATHLEN); - strlcat(file, "~", MAXPATHLEN); + strlcpy(file, MANDOC_DB, PATH_MAX); + strlcat(file, "~", PATH_MAX); if (-1 == rename(file, MANDOC_DB)) perror(MANDOC_DB); } @@ -1908,7 +1908,7 @@ dbclose(const char *base, int real) static int dbopen(const char *base, int real) { - char file[MAXPATHLEN]; + char file[PATH_MAX]; const char *sql; int rc, ofl; size_t sz; @@ -1916,11 +1916,11 @@ dbopen(const char *base, int real) if (nodb) return(1); - sz = strlcpy(file, MANDOC_DB, MAXPATHLEN); + sz = strlcpy(file, MANDOC_DB, PATH_MAX); if ( ! real) - sz = strlcat(file, "~", MAXPATHLEN); + sz = strlcat(file, "~", PATH_MAX); - if (sz >= MAXPATHLEN) { + if (sz >= PATH_MAX) { fprintf(stderr, "%s: Path too long\n", file); return(0); } @@ -17,10 +17,10 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <sys/param.h> #include <assert.h> #include <getopt.h> +#include <limits.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> @@ -40,7 +40,7 @@ main(int argc, char *argv[]) struct mansearch search; struct manpage *res; char *conf_file, *defpaths, *auxpaths, *cp; - char buf[MAXPATHLEN]; + char buf[PATH_MAX]; const char *cmd; struct manpaths paths; char *progname; @@ -132,7 +132,7 @@ main(int argc, char *argv[]) } show: cmd = res[i - 1].form ? "mandoc" : "cat"; - strlcpy(buf, res[i - 1].file, MAXPATHLEN); + strlcpy(buf, res[i - 1].file, PATH_MAX); free(res); show(cmd, buf); @@ -19,10 +19,6 @@ #include "config.h" #endif -#ifdef USE_MANPATH -#include <sys/param.h> -#endif - #include <assert.h> #include <ctype.h> #include <limits.h> @@ -44,7 +40,7 @@ manpath_parse(struct manpaths *dirs, const char *file, char *defp, char *auxp) { #ifdef USE_MANPATH - char cmd[(MAXPATHLEN * 3) + 20]; + char cmd[(PATH_MAX * 3) + 20]; FILE *stream; char *buf; size_t sz, bsz; diff --git a/mansearch.c b/mansearch.c index c82dbf97..472e1cb5 100644 --- a/mansearch.c +++ b/mansearch.c @@ -18,11 +18,10 @@ #include "config.h" #endif -#include <sys/param.h> - #include <assert.h> #include <fcntl.h> #include <getopt.h> +#include <limits.h> #include <stdio.h> #include <stdint.h> #include <stddef.h> @@ -131,7 +130,7 @@ mansearch(const struct mansearch *search, { int fd, rc, c; int64_t id; - char buf[MAXPATHLEN]; + char buf[PATH_MAX]; char *sql; struct expr *e, *ep; sqlite3 *db; @@ -168,7 +167,7 @@ mansearch(const struct mansearch *search, * on our current directory from which to start the chdir(). */ - if (NULL == getcwd(buf, MAXPATHLEN)) { + if (NULL == getcwd(buf, PATH_MAX)) { perror(NULL); goto out; } else if (-1 == (fd = open(buf, O_RDONLY, 0))) { @@ -266,9 +265,9 @@ mansearch(const struct mansearch *search, (*res, maxres * sizeof(struct manpage)); } strlcpy((*res)[cur].file, - paths->paths[i], MAXPATHLEN); - strlcat((*res)[cur].file, "/", MAXPATHLEN); - strlcat((*res)[cur].file, mp->file, MAXPATHLEN); + paths->paths[i], PATH_MAX); + strlcat((*res)[cur].file, "/", PATH_MAX); + strlcat((*res)[cur].file, mp->file, PATH_MAX); (*res)[cur].desc = mp->desc; (*res)[cur].form = mp->form; free(mp->file); diff --git a/mansearch.h b/mansearch.h index 10584c63..a72d5901 100644 --- a/mansearch.h +++ b/mansearch.h @@ -61,7 +61,7 @@ __BEGIN_DECLS struct manpage { - char file[MAXPATHLEN]; /* prefixed by manpath */ + char file[PATH_MAX]; /* prefixed by manpath */ char *desc; /* description of manpage */ int form; /* 0 == catpage */ }; |