Bug 46169 - Pointer error in FcConfigGlobMatch
authorAkira TAGOH <akira@tagoh.org>
Wed, 22 Feb 2012 07:30:05 +0000 (16:30 +0900)
committerAkira TAGOH <akira@tagoh.org>
Wed, 22 Feb 2012 07:30:05 +0000 (16:30 +0900)
Fix possibly accessing the invalid memory and a crash in the worst case
when the glob string is longer than the string.

src/fccfg.c

index 09c5991..9395f74 100644 (file)
@@ -2023,7 +2023,15 @@ FcConfigGlobMatch (const FcChar8    *glob,
                return FcTrue;
            /* short circuit another common case */
            if (strchr ((char *) glob, '*') == 0)
-               string += strlen ((char *) string) - strlen ((char *) glob);
+           {
+               size_t l1, l2;
+
+               l1 = strlen ((char *) string);
+               l2 = strlen ((char *) glob);
+               if (l1 < l2)
+                   return FcFalse;
+               string += (l1 - l2);
+           }
            while (*string)
            {
                if (FcConfigGlobMatch (glob, string))