1 diff -Nur XFree86-4.0.2.org/xc/programs/xfs/difs/fonts.c XFree86-4.0.2/xc/programs/xfs/difs/fonts.c
2 --- XFree86-4.0.2.org/xc/programs/xfs/difs/fonts.c Thu Dec 14 20:54:53 2000
3 +++ XFree86-4.0.2/xc/programs/xfs/difs/fonts.c Thu Dec 21 09:26:42 2000
9 + * Extract a single element from the font path string starting at
10 + * pnt. The font path element will be returned, and pnt will be
11 + * updated to point to the start of the next element, or set to
12 + * NULL if there are no more.
21 + *pnt = index(*pnt, ',');
30 + * xf86ValidateFontPath --
31 + * Validates the user-specified font path. Each element that
32 + * begins with a '/' is checked to make sure the directory exists.
33 + * If the directory exists, the existence of a file named 'fonts.dir'
34 + * is checked. If either check fails, an error is printed and the
35 + * element is removed from the font path.
37 +#define DIR_FILE "/fonts.dir"
38 +#define CHECK_TYPE(mode, type) ((S_IFMT & (mode)) == (type))
40 +xf86ValidateFontPath(path)
43 + char *tmp_path, *out_pnt, *path_elem, *next, *p1, *dir_elem;
44 + struct stat stat_buf;
48 + tmp_path = (char *)calloc(1,strlen(path)+1);
52 + while (next != NULL) {
53 + path_elem = xf86GetPathElem(&next);
55 + if (*path_elem == '/') {
56 + dir_elem = (char *)calloc(1, strlen(path_elem) + 1);
57 + if ((p1 = strchr(path_elem, ':')) != 0)
59 + /* OS/2 must prepend X11ROOT */
60 + if (*path_elem == '/') {
61 + path_elem = (char*)__XOS2RedirRoot(path_elem);
62 + dir_elem = (char*)calloc(1, strlen(path_elem) + 1);
63 + if (p1 = strchr(path_elem+2, ':'))
65 + dirlen = p1 - path_elem;
67 + dirlen = strlen(path_elem);
68 + strncpy(dir_elem, path_elem, dirlen);
69 + dir_elem[dirlen] = '\0';
70 + flag = stat(dir_elem, &stat_buf);
72 + if (!CHECK_TYPE(stat_buf.st_mode, S_IFDIR))
75 + printf("warning!\n");
76 + ErrorF("Warning: The directory \"%s\" does not exist.\n", dir_elem);
77 + ErrorF(" Entry deleted from font path.\n");
81 + p1 = (char *)malloc(strlen(dir_elem)+strlen(DIR_FILE)+1);
82 + strcpy(p1, dir_elem);
83 + strcat(p1, DIR_FILE);
84 + flag = stat(p1, &stat_buf);
86 + if (!CHECK_TYPE(stat_buf.st_mode, S_IFREG))
92 + ErrorF("Warning: 'fonts.dir' not found (or not valid) in \"%s\".\n",
94 + ErrorF(" Entry deleted from font path.\n");
95 + ErrorF(" (Run 'mkfontdir' on \"%s\").\n", dir_elem);
103 + * Either an OK directory, or a font server name. So add it to
106 + if (out_pnt != tmp_path)
108 + strcat(out_pnt, path_elem);
109 + out_pnt += strlen(path_elem);
115 * note that the font wakeup queue is not refcounted. this is because
116 * an fpe needs to be added when it's inited, and removed when it's finally
117 * freed, in order to handle any data that isn't requested, like FS events.
124 + fixedpath = xf86ValidateFontPath(str);
126 - len = strlen(str) + 1;
127 + len = strlen(fixedpath) + 1;
129 paths = p = (char *) ALLOCATE_LOCAL(len);
134 err = set_font_path_elements(npaths, paths, badpath);
137 DEALLOCATE_LOCAL(paths);