tweaks: rename two variables, to be shorter and without abbreviations

master
Benno Schulenberg 2020-06-21 09:05:41 +02:00
parent b086d0bad0
commit bb496bf456
1 changed files with 13 additions and 14 deletions

View File

@ -1476,33 +1476,32 @@ void init_operating_dir(void)
} }
/* Check whether the given path is outside of the operating directory. /* Check whether the given path is outside of the operating directory.
* Return TRUE if it is, and FALSE otherwise. If allow_tabcomp is TRUE, * Return TRUE if it is, and FALSE otherwise. If tabbing is TRUE,
* incomplete names that can grow into matches for the operating directory * incomplete names that can grow into matches for the operating directory
* are considered to be inside, so that tab completion will work. */ * are considered to be inside, so that tab completion will work. */
bool outside_of_confinement(const char *currpath, bool allow_tabcomp) bool outside_of_confinement(const char *somepath, bool tabbing)
{ {
char *fullpath;
bool is_inside, begins_to_be; bool is_inside, begins_to_be;
char *fullpath;
/* If no operating directory is set, there is nothing to check. */ /* If no operating directory is set, there is nothing to check. */
if (operating_dir == NULL) if (operating_dir == NULL)
return FALSE; return FALSE;
fullpath = get_full_path(currpath); fullpath = get_full_path(somepath);
/* If fullpath is NULL, it means some directory in the path doesn't /* When we can't get an absolute path, it means some directory in the path
* exist or is unreadable. If allow_tabcomp is FALSE, then currpath * doesn't exist or is unreadable. When not doing tab completion, somepath
* is what the user typed somewhere. We don't want to report a * is what the user typed somewhere. We don't want to report a non-existent
* non-existent directory as being outside the operating directory, * directory as being outside the operating directory, so we return FALSE.
* so we return FALSE. If allow_tabcomp is TRUE, then currpath * When the user is doing tab completion, then somepath exists but is not
* exists, but is not executable. So we say it is outside the * executable. So we say it is outside the operating directory. */
* operating directory. */
if (fullpath == NULL) if (fullpath == NULL)
return allow_tabcomp; return tabbing;
is_inside = (strstr(fullpath, operating_dir) == fullpath); is_inside = (strstr(fullpath, operating_dir) == fullpath);
begins_to_be = (allow_tabcomp && begins_to_be = (tabbing && strstr(operating_dir, fullpath) == operating_dir);
strstr(operating_dir, fullpath) == operating_dir);
free(fullpath); free(fullpath);
return (!is_inside && !begins_to_be); return (!is_inside && !begins_to_be);