]> git.pld-linux.org Git - packages/XFree86.git/blame - XFree86-xfs.patch
- 4.8.0 (probably the last XFree86 version ever, for comparison and archival reasons)
[packages/XFree86.git] / XFree86-xfs.patch
CommitLineData
b19d4d8b
JR
1diff -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
4@@ -108,6 +108,113 @@
5 }
6
7 /*
8+ * xf86GetPathElem --
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.
13+ */
14+char *
15+xf86GetPathElem(pnt)
16+ char **pnt;
17+{
18+ char *p1;
19+
20+ p1 = *pnt;
21+ *pnt = index(*pnt, ',');
22+ if (*pnt != NULL) {
23+ **pnt = '\0';
24+ *pnt += 1;
25+ }
26+ return(p1);
27+}
28+
29+/*
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.
36+ */
37+#define DIR_FILE "/fonts.dir"
38+#define CHECK_TYPE(mode, type) ((S_IFMT & (mode)) == (type))
39+static char *
40+xf86ValidateFontPath(path)
41+ char *path;
42+{
43+ char *tmp_path, *out_pnt, *path_elem, *next, *p1, *dir_elem;
44+ struct stat stat_buf;
45+ int flag;
46+ int dirlen;
47+
48+ tmp_path = (char *)calloc(1,strlen(path)+1);
49+ out_pnt = tmp_path;
50+ path_elem = NULL;
51+ next = path;
52+ while (next != NULL) {
53+ path_elem = xf86GetPathElem(&next);
54+#ifndef __EMX__
55+ if (*path_elem == '/') {
56+ dir_elem = (char *)calloc(1, strlen(path_elem) + 1);
57+ if ((p1 = strchr(path_elem, ':')) != 0)
58+#else
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, ':'))
64+#endif
65+ dirlen = p1 - path_elem;
66+ else
67+ dirlen = strlen(path_elem);
68+ strncpy(dir_elem, path_elem, dirlen);
69+ dir_elem[dirlen] = '\0';
70+ flag = stat(dir_elem, &stat_buf);
71+ if (flag == 0)
72+ if (!CHECK_TYPE(stat_buf.st_mode, S_IFDIR))
73+ flag = -1;
74+ if (flag != 0) {
75+ printf("warning!\n");
76+ ErrorF("Warning: The directory \"%s\" does not exist.\n", dir_elem);
77+ ErrorF(" Entry deleted from font path.\n");
78+ continue;
79+ }
80+ else {
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);
85+ if (flag == 0)
86+ if (!CHECK_TYPE(stat_buf.st_mode, S_IFREG))
87+ flag = -1;
88+#ifndef __EMX__
89+ free(p1);
90+#endif
91+ if (flag != 0) {
92+ ErrorF("Warning: 'fonts.dir' not found (or not valid) in \"%s\".\n",
93+ dir_elem);
94+ ErrorF(" Entry deleted from font path.\n");
95+ ErrorF(" (Run 'mkfontdir' on \"%s\").\n", dir_elem);
96+ continue;
97+ }
98+ }
99+ free(dir_elem);
100+ }
101+
102+ /*
103+ * Either an OK directory, or a font server name. So add it to
104+ * the path.
105+ */
106+ if (out_pnt != tmp_path)
107+ *out_pnt++ = ',';
108+ strcat(out_pnt, path_elem);
109+ out_pnt += strlen(path_elem);
110+ }
111+ return(tmp_path);
112+}
113+
114+/*
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.
118@@ -744,8 +851,12 @@
119 *end,
120 *p;
121 int err;
122+ char *fixedpath;
123+
124+ fixedpath = xf86ValidateFontPath(str);
125
126- len = strlen(str) + 1;
127+ len = strlen(fixedpath) + 1;
128+ str = fixedpath;
129 paths = p = (char *) ALLOCATE_LOCAL(len);
130 npaths = 0;
131
132@@ -765,6 +876,7 @@
133
134 err = set_font_path_elements(npaths, paths, badpath);
135
136+ free(fixedpath);
137 DEALLOCATE_LOCAL(paths);
138
139 return err;
This page took 0.102696 seconds and 4 git commands to generate.