summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mandocdb.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/mandocdb.c b/mandocdb.c
index e3362b84..26d1c1ce 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -272,7 +272,9 @@ main(int argc, char *argv[])
struct manpaths dirs;
enum op op; /* current operation */
const char *dir;
- char ibuf[MAXPATHLEN], /* index fname */
+ char *cp;
+ char pbuf[PATH_MAX],
+ ibuf[MAXPATHLEN], /* index fname */
fbuf[MAXPATHLEN]; /* btree fname */
int ch, i, flags;
DB *idx, /* index database */
@@ -413,10 +415,15 @@ main(int argc, char *argv[])
*/
if (argc > 0) {
- dirs.paths = mandoc_malloc(argc * sizeof(char *));
+ dirs.paths = mandoc_calloc(argc, sizeof(char *));
dirs.sz = argc;
- for (i = 0; i < argc; i++)
- dirs.paths[i] = mandoc_strdup(argv[i]);
+ for (i = 0; i < argc; i++) {
+ if (NULL == (cp = realpath(argv[i], pbuf))) {
+ perror(argv[i]);
+ goto out;
+ }
+ dirs.paths[i] = mandoc_strdup(cp);
+ }
} else
manpath_parse(&dirs, NULL, NULL);