[tbb-commits] [tor-browser/tor-browser-52.8.0esr-7.5-1] Bug 1448771 - Merge fix from upstream. r=ryanvm, a=RyanVM

gk at torproject.org gk at torproject.org
Wed Jun 20 11:38:51 UTC 2018


commit 12148cf644e5820182306788a3d3309baf8c2720
Author: Jonathan Kew <jkew at mozilla.com>
Date:   Mon Mar 26 20:35:48 2018 +0100

    Bug 1448771 - Merge fix from upstream. r=ryanvm, a=RyanVM
    
    --HG--
    extra : source : f5db47b5c6416a3cef546de1aa9089d98109f95f
---
 intl/hyphenation/hyphen/hyphen.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/intl/hyphenation/hyphen/hyphen.c b/intl/hyphenation/hyphen/hyphen.c
index 9a132d0262f2..9f2b7112c848 100644
--- a/intl/hyphenation/hyphen/hyphen.c
+++ b/intl/hyphenation/hyphen/hyphen.c
@@ -438,11 +438,25 @@ for (k = 0; k < 2; k++) {
   }
 
   if (k == 0 || nextlevel) {
-    while (fgets (buf, sizeof(buf), f) != NULL) {
+    while (fgets(buf, sizeof(buf), f) != NULL) {
+      
+      /* discard lines that don't fit in buffer */
+      if (!feof(f) && strchr(buf, '\n') == NULL) {
+        int c;
+        while ((c = fgetc(f)) != '\n' && c != EOF);
+        /* issue warning if not a comment */
+        if (buf[0] != '%') {
+          fprintf(stderr, "Warning: skipping too long pattern (more than %lu chars)\n", sizeof(buf));
+        }
+        continue;
+      }
+      
       if (strncmp(buf, "NEXTLEVEL", 9) == 0) {
-	nextlevel = 1;
-	break;
-      } else if (buf[0] != '%') hnj_hyphen_load_line(buf, dict[k], hashtab);
+        nextlevel = 1;
+        break;
+      } else if (buf[0] != '%') {
+        hnj_hyphen_load_line(buf, dict[k], hashtab);
+      }
     }
   } else if (k == 1) {
     /* default first level: hyphen and ASCII apostrophe */



More information about the tbb-commits mailing list