Add a condition to FcCacheOffsetsValid() for detecting empty data of cache 24/155324/1 accepted/tizen/unified/20171025.075138 submit/tizen/20171020.120936
authorYoungbok Shin <youngb.shin@samsung.com>
Fri, 13 Oct 2017 02:24:56 +0000 (11:24 +0900)
committerYoungbok Shin <youngb.shin@samsung.com>
Fri, 13 Oct 2017 02:31:18 +0000 (11:31 +0900)
This patch was suggested by Akira TAGOH in the following bug report.
https://bugs.freedesktop.org/show_bug.cgi?id=103237

I made TIZEN_ONLY comments because it is not applied in upstream yet.

@tizen_fix

Change-Id: I261a3ae2f6abc37173a861a7cbef48ba68a19fb9

src/fccache.c

index 6f3c68a..f9e66e8 100644 (file)
@@ -642,12 +642,22 @@ FcCacheOffsetsValid (FcCache *cache)
             FcValueListPtr      l;
            char                *last_offset;
 
+            /* TIZEN_ONLY(20171013): Add a condition to FcCacheOffsetsValid() for detecting empty data of cache
             if ((char *) font < base ||
                 (char *) font > end - sizeof (FcFontSet) ||
                 font->elts_offset < 0 ||
                 font->elts_offset > end - (char *) font ||
                 font->num > (end - (char *) font - font->elts_offset) / sizeof (FcPatternElt))
                 return FcFalse;
+             */
+            if ((char *) font < base ||
+                (char *) font > end - sizeof (FcFontSet) ||
+                font->elts_offset < 0 ||
+                font->elts_offset > end - (char *) font ||
+                font->num > (end - (char *) font - font->elts_offset) / sizeof (FcPatternElt) ||
+                !FcRefIsConst (&font->ref))
+                return FcFalse;
+            /* END */
 
 
             e = FcPatternElts(font);