xserver: Branch 'master'

Adam Jackson ajax at kemper.freedesktop.org
Fri Jul 21 21:05:16 PDT 2006


 hw/xfree86/loader/loadmod.c |   44 ++++++++++++++++----------------------------
 1 files changed, 16 insertions(+), 28 deletions(-)

New commits:
diff-tree 1c4f90b1d05d4c49279f3224a6dd94850a6bd8d0 (from 114264584ca43091a5e07282566a30a6378a1502)
Author: Adam Jackson <ajax at theobromine.nwnk.net>
Date:   Fri Jul 21 23:03:21 2006 -0400

    Open-coded path checks make baby Jesus cry.

diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index 53dcffe..12f5dc9 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -115,6 +115,17 @@ FreeStringList(char **paths)
 
 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
  * elements, rejecting any that are not full absolute paths, and appending
@@ -138,13 +149,7 @@ InitPathList(const char *path)
 	return NULL;
     elem = strtok(fullpath, ",");
     while (elem) {
-	/* Only allow fully specified paths */
-#ifndef __UNIXOS2__
-	if (*elem == '/')
-#else
-	if (*elem == '/' || (strlen(elem) > 2 && isalpha(elem[0]) &&
-			     elem[1] == ':' && elem[2] == '/'))
-#endif
+	if (PathIsAbsolute(elem))
 	{
 	    len = strlen(elem);
 	    addslash = (elem[len - 1] != '/');
@@ -750,13 +755,7 @@ LoadSubModule(ModuleDescPtr parent, cons
 
     xf86MsgVerb(X_INFO, 3, "Loading sub module \"%s\"\n", module);
 
-    /* Absolute module paths are not allowed here */
-#ifndef __UNIXOS2__
-    if (module[0] == '/')
-#else
-    if (isalpha(module[0]) && module[1] == ':' && module[2] == '/')
-#endif
-    {
+    if (PathIsAbsolute(module)) {
 	xf86Msg(X_ERROR,
 		"LoadSubModule: Absolute module path not permitted: \"%s\"\n",
 		module);
@@ -786,12 +785,7 @@ LoadSubModuleLocal(ModuleDescPtr parent,
 
     xf86MsgVerb(X_INFO, 3, "Loading local sub module \"%s\"\n", module);
 
-    /* Absolute module paths are not allowed here */
-#ifndef __UNIXOS2__
-    if (module[0] == '/')
-#else
-    if (isalpha(module[0]) && module[1] == ':' && module[2] == '/')
-#endif
+    if (PathIsAbsolute(module))
     {
 	xf86Msg(X_ERROR,
 		"LoadSubModule: Absolute module path not permitted: \"%s\"\n",
@@ -908,14 +902,8 @@ doLoadModule(const char *module, const c
      * if the module name is not a full pathname, we need to
      * check the elements in the path
      */
-#ifndef __UNIXOS2__
-    if (module[0] == '/')
-	found = xstrdup(module);
-#else
-    /* accept a drive name here */
-    if (isalpha(module[0]) && module[1] == ':' && module[2] == '/')
-	found = xstrdup(module);
-#endif
+    if (PathIsAbsolute(module))
+	xstrdup(module);
     path_elem = pathlist;
     while (!found && *path_elem != NULL) {
 	found = FindModule(m, *path_elem, subdirlist, patterns);



More information about the xorg-commit mailing list