freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master 757bdf1: [cff] Fix segv.


From: Werner LEMBERG
Subject: [freetype2] master 757bdf1: [cff] Fix segv.
Date: Mon, 13 Aug 2018 20:02:44 -0400 (EDT)

branch: master
commit 757bdf1aef3d93a27968857ac5b4435a52fa24a0
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>

    [cff] Fix segv.
    
    Reported as
    
      https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9864
    
    * src/psaux/cffdecode.c (cff_decoder_parse_charstrings)
    <cff_op_random> [CFF_CONFIG_OPTION_OLD_ENGINE]: Use top dict's
    `random' field directly if parsing dictionaries.
---
 ChangeLog             | 12 ++++++++++++
 src/psaux/cffdecode.c | 20 ++++++++++++--------
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5b43aa7..227e94e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2018-08-14  Werner Lemberg  <address@hidden>
+
+       [cff] Fix segv.
+
+       Reported as
+
+         https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9864
+
+       * src/psaux/cffdecode.c (cff_decoder_parse_charstrings)
+       <cff_op_random> [CFF_CONFIG_OPTION_OLD_ENGINE]: Use top dict's
+       `random' field directly if parsing dictionaries.
+
 2018-08-13  Alexei Podtelezhnikov  <address@hidden>
 
        [bdf] Use unsigned types.
diff --git a/src/psaux/cffdecode.c b/src/psaux/cffdecode.c
index 024eb9c..3f4ea15 100644
--- a/src/psaux/cffdecode.c
+++ b/src/psaux/cffdecode.c
@@ -1712,16 +1712,20 @@
           break;
 
         case cff_op_random:
-          FT_TRACE4(( " random\n" ));
+          {
+            FT_UInt32*  randval = in_dict ? &decoder->cff->top_font.random
+                                          : &decoder->current_subfont->random;
 
-          /* only use the lower 16 bits of `random'  */
-          /* to generate a number in the range (0;1] */
-          args[0] = (FT_Fixed)
-                      ( ( decoder->current_subfont->random & 0xFFFF ) + 1 );
-          args++;
 
-          decoder->current_subfont->random =
-            cff_random( decoder->current_subfont->random );
+            FT_TRACE4(( " random\n" ));
+
+            /* only use the lower 16 bits of `random'  */
+            /* to generate a number in the range (0;1] */
+            args[0] = (FT_Fixed)( ( *randval & 0xFFFF ) + 1 );
+            args++;
+
+            *randval = cff_random( *randval );
+          }
           break;
 
         case cff_op_mul:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]