Open-coded path checks make baby Jesus cry.
This commit is contained in:
		
							parent
							
								
									114264584c
								
							
						
					
					
						commit
						1c4f90b1d0
					
				| 
						 | 
					@ -115,6 +115,17 @@ FreeStringList(char **paths)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static char **defaultPathList = NULL;
 | 
					static char **defaultPathList = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static Bool
 | 
				
			||||||
 | 
					PathIsAbsolute(const char *path)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#ifdef __UNIXOS2__
 | 
				
			||||||
 | 
					    return (*path == '/' || (strlen(path) > 2 && isalpha(elem[0]) &&
 | 
				
			||||||
 | 
							elem[1] == ':' && elem[2] == '/'));
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					    return (*path == '/');
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					}	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Convert a comma-separated path into a NULL-terminated array of path
 | 
					 * Convert a comma-separated path into a NULL-terminated array of path
 | 
				
			||||||
 * elements, rejecting any that are not full absolute paths, and appending
 | 
					 * elements, rejecting any that are not full absolute paths, and appending
 | 
				
			||||||
| 
						 | 
					@ -138,13 +149,7 @@ InitPathList(const char *path)
 | 
				
			||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
    elem = strtok(fullpath, ",");
 | 
					    elem = strtok(fullpath, ",");
 | 
				
			||||||
    while (elem) {
 | 
					    while (elem) {
 | 
				
			||||||
	/* Only allow fully specified paths */
 | 
						if (PathIsAbsolute(elem))
 | 
				
			||||||
#ifndef __UNIXOS2__
 | 
					 | 
				
			||||||
	if (*elem == '/')
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
	if (*elem == '/' || (strlen(elem) > 2 && isalpha(elem[0]) &&
 | 
					 | 
				
			||||||
			     elem[1] == ':' && elem[2] == '/'))
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	    len = strlen(elem);
 | 
						    len = strlen(elem);
 | 
				
			||||||
	    addslash = (elem[len - 1] != '/');
 | 
						    addslash = (elem[len - 1] != '/');
 | 
				
			||||||
| 
						 | 
					@ -750,13 +755,7 @@ LoadSubModule(ModuleDescPtr parent, const char *module,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    xf86MsgVerb(X_INFO, 3, "Loading sub module \"%s\"\n", module);
 | 
					    xf86MsgVerb(X_INFO, 3, "Loading sub module \"%s\"\n", module);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Absolute module paths are not allowed here */
 | 
					    if (PathIsAbsolute(module)) {
 | 
				
			||||||
#ifndef __UNIXOS2__
 | 
					 | 
				
			||||||
    if (module[0] == '/')
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
    if (isalpha(module[0]) && module[1] == ':' && module[2] == '/')
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
	xf86Msg(X_ERROR,
 | 
						xf86Msg(X_ERROR,
 | 
				
			||||||
		"LoadSubModule: Absolute module path not permitted: \"%s\"\n",
 | 
							"LoadSubModule: Absolute module path not permitted: \"%s\"\n",
 | 
				
			||||||
		module);
 | 
							module);
 | 
				
			||||||
| 
						 | 
					@ -786,12 +785,7 @@ LoadSubModuleLocal(ModuleDescPtr parent, const char *module,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    xf86MsgVerb(X_INFO, 3, "Loading local sub module \"%s\"\n", module);
 | 
					    xf86MsgVerb(X_INFO, 3, "Loading local sub module \"%s\"\n", module);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Absolute module paths are not allowed here */
 | 
					    if (PathIsAbsolute(module))
 | 
				
			||||||
#ifndef __UNIXOS2__
 | 
					 | 
				
			||||||
    if (module[0] == '/')
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
    if (isalpha(module[0]) && module[1] == ':' && module[2] == '/')
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
	xf86Msg(X_ERROR,
 | 
						xf86Msg(X_ERROR,
 | 
				
			||||||
		"LoadSubModule: Absolute module path not permitted: \"%s\"\n",
 | 
							"LoadSubModule: Absolute module path not permitted: \"%s\"\n",
 | 
				
			||||||
| 
						 | 
					@ -908,14 +902,8 @@ doLoadModule(const char *module, const char *path, const char **subdirlist,
 | 
				
			||||||
     * if the module name is not a full pathname, we need to
 | 
					     * if the module name is not a full pathname, we need to
 | 
				
			||||||
     * check the elements in the path
 | 
					     * check the elements in the path
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
#ifndef __UNIXOS2__
 | 
					    if (PathIsAbsolute(module))
 | 
				
			||||||
    if (module[0] == '/')
 | 
						xstrdup(module);
 | 
				
			||||||
	found = xstrdup(module);
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
    /* accept a drive name here */
 | 
					 | 
				
			||||||
    if (isalpha(module[0]) && module[1] == ':' && module[2] == '/')
 | 
					 | 
				
			||||||
	found = xstrdup(module);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
    path_elem = pathlist;
 | 
					    path_elem = pathlist;
 | 
				
			||||||
    while (!found && *path_elem != NULL) {
 | 
					    while (!found && *path_elem != NULL) {
 | 
				
			||||||
	found = FindModule(m, *path_elem, subdirlist, patterns);
 | 
						found = FindModule(m, *path_elem, subdirlist, patterns);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue