diff --git a/src/ChangeLog b/src/ChangeLog index 0fbbb8625adab14e4ab88b4b7bf44e5aad302da7..dd2e2cc146eaf534065e7a9f28e26bfec490abf7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2009-08-03 Derek R. Price <derek@ximbiot.com> + + * parseinfo.c (parse_config): Find alternate config files correctly. + 2009-07-18 Derek R. Price <derek@ximbiot.com> * subr.c (sleep_past): Don't assume that time() called after diff --git a/src/parseinfo.c b/src/parseinfo.c index 59f33f18c96bd4650d7f9f34552e2f6989137ab1..6743b939dfda92330c8165a1143bb03a9100ee17 100644 --- a/src/parseinfo.c +++ b/src/parseinfo.c @@ -19,6 +19,9 @@ /* Verify interface. */ #include "parseinfo.h" +/* GNULIB includes. */ +#include "quote.h" + /* CVS includes. */ #include "history.h" #include "logmsg.h" @@ -441,13 +444,33 @@ parse_config (const char *cvsroot, const char *path) { char *nprefix; + /* Allowed prefix == "/" is a special case. */ + if (STREQ (*prefix, "/")) { + approved = true; + break; + } + if (!isreadable (*prefix)) continue; nprefix = xcanonicalize_file_name (*prefix); - if (STRNEQ (nprefix, npath, strlen (nprefix)) - && (((*prefix)[strlen (*prefix)] != '/' - && strlen (npath) == strlen (nprefix)) - || ((*prefix)[strlen (*prefix)] == '/' - && npath[strlen (nprefix)] == '/'))) + if (/* Strings equal to length of allowed prefix. */ + STRNEQ (nprefix, npath, strlen (nprefix)) + && ( /* The allowed prefix specifies a file (it does not have + * a trailing slash). + */ + (*prefix)[strlen (*prefix) - 1] != '/' + /* ...and has the same length as the user specified file + * (which means it is an exact match since it matched to + * the length of nprefix, above). + */ + && strlen (npath) == strlen (nprefix) + || /* The allowed prefix specifies a directory (it has a + * trailing slash). + */ + (*prefix)[strlen (*prefix) - 1] == '/' + /* ...and the user specified path is under the tree + * specified by prefix. + */ + && npath[strlen (nprefix)] == '/')) approved = true; free (nprefix); if (approved) break;