Improve check for an existing "built-ins" in the fontpath so it doesn't get misled if "built-ins" exists as a substring of a path or hostname.
Also fix some signedness mismatch warnings in that code Signed-off-by: Jon TURNEY <[email protected]> --- dix/dixfonts.c | 42 ++++++++++++++++++++++++++++-------------- 1 files changed, 28 insertions(+), 14 deletions(-) diff --git a/dix/dixfonts.c b/dix/dixfonts.c index c8b7bdc..398782b 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -1813,27 +1813,41 @@ SetDefaultFontPath(char *path) unsigned char *cp, *pp, *nump, - *temp_path, - *start, - *end, *newpath; + char *start, + *end, + *temp_path; int num = 1, len, err, size = 0, bad; - /* ensure temp_path contains "built-ins" */ - start = strstr(path, "built-ins"); - end = start + strlen("built-ins"); - if (start == NULL || - !((start == path || start[-1] == ',') && (!*end || *end == ','))) { - temp_path = Xprintf("%s%sbuilt-ins", path, *path ? "," : ""); - } else { - temp_path = Xstrdup(path); - } - if (!temp_path) - return BadAlloc; + /* ensure temp_path contains "built-ins" */ + start = path; + while (1) { + end = strstr(start, ","); + if (end == NULL) + end = start + strlen(start); + + if ((end - start) == strlen("built-ins") && strncmp(start, "built-ins", strlen("built-ins")) == 0) + break; + + if (*end == '\0') + { + start = NULL; + break; + } + + start = end + 1; + } + if (!start) { + temp_path = Xprintf("%s%sbuilt-ins", path, *path ? "," : ""); + } else { + temp_path = Xstrdup(path); + } + if (!temp_path) + return BadAlloc; /* get enough for string, plus values -- use up commas */ len = strlen(temp_path) + 1; -- 1.6.4.2 _______________________________________________ xorg-devel mailing list [email protected] http://lists.x.org/mailman/listinfo/xorg-devel
