groff-commit
[Top][All Lists]
Advanced

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

[Groff-commit] groff ChangeLog src/roff/troff/charinfo.h src/r...


From: Werner LEMBERG
Subject: [Groff-commit] groff ChangeLog src/roff/troff/charinfo.h src/r...
Date: Sun, 19 Dec 2010 20:47:38 +0000

CVSROOT:        /cvsroot/groff
Module name:    groff
Changes by:     Werner LEMBERG <wl>     10/12/19 20:47:38

Modified files:
        .              : ChangeLog 
        src/roff/troff : charinfo.h input.cpp 

Log message:
        Protect `.class' against cyclic nesting.
        
        * src/roff/troff/charinfo.h (charinfo::contains): Add optional
        boolean argument.
        * src/roff/troff/input.cpp (define_class, charinfo::contains): Check
        for cyclic nesting.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/groff/ChangeLog?cvsroot=groff&r1=1.1259&r2=1.1260
http://cvs.savannah.gnu.org/viewcvs/groff/src/roff/troff/charinfo.h?cvsroot=groff&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/groff/src/roff/troff/input.cpp?cvsroot=groff&r1=1.66&r2=1.67

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/groff/groff/ChangeLog,v
retrieving revision 1.1259
retrieving revision 1.1260
diff -u -b -r1.1259 -r1.1260
--- ChangeLog   18 Dec 2010 09:13:16 -0000      1.1259
+++ ChangeLog   19 Dec 2010 20:47:38 -0000      1.1260
@@ -1,3 +1,12 @@
+2010-12-19  Werner LEMBERG  <address@hidden>
+
+       Protect `.class' against cyclic nesting.
+
+       * src/roff/troff/charinfo.h (charinfo::contains): Add optional
+       boolean argument.
+       * src/roff/troff/input.cpp (define_class, charinfo::contains): Check
+       for cyclic nesting.
+
 2010-12-18  Werner LEMBERG  <address@hidden>
 
        Improve CJK support with new values for `.cflags'.

Index: src/roff/troff/charinfo.h
===================================================================
RCS file: /cvsroot/groff/groff/src/roff/troff/charinfo.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- src/roff/troff/charinfo.h   18 Dec 2010 09:13:18 -0000      1.18
+++ src/roff/troff/charinfo.h   19 Dec 2010 20:47:38 -0000      1.19
@@ -105,9 +105,9 @@
   void add_to_class(int, int);
   void add_to_class(charinfo *);
   bool is_class();
-  bool contains(int);
-  bool contains(symbol);
-  bool contains(charinfo *);
+  bool contains(int, bool = false);
+  bool contains(symbol, bool = false);
+  bool contains(charinfo *, bool = false);
 };
 
 charinfo *get_charinfo(symbol);

Index: src/roff/troff/input.cpp
===================================================================
RCS file: /cvsroot/groff/groff/src/roff/troff/input.cpp,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- src/roff/troff/input.cpp    18 Dec 2010 09:13:18 -0000      1.66
+++ src/roff/troff/input.cpp    19 Dec 2010 20:47:38 -0000      1.67
@@ -6788,8 +6788,14 @@
       child1 = child2 = 0;
     }
     else if (child1 != 0) {
-      if (child1->is_class())
+      if (child1->is_class()) {
+       if (ci == child1) {
+         warning(WARN_SYNTAX, "invalid cyclic class nesting");
+         skip_line();
+         return;
+       }
        ci->add_to_class(child1);
+      }
       else {
        int u1 = child1->get_unicode_code();
        if (u1 < 0) {
@@ -6812,8 +6818,14 @@
     }
   }
   if (child1 != 0) {
-    if (child1->is_class())
+    if (child1->is_class()) {
+      if (ci == child1) {
+       warning(WARN_SYNTAX, "invalid cyclic class nesting");
+       skip_line();
+       return;
+      }
       ci->add_to_class(child1);
+    }
     else {
       int u1 = child1->get_unicode_code();
       if (u1 < 0) {
@@ -8560,8 +8572,14 @@
   return number;
 }
 
-bool charinfo::contains(int c)
+bool charinfo::contains(int c, bool already_called)
 {
+  if (already_called) {
+    warning(WARN_SYNTAX,
+           "cyclic nested class detected while processing character code %1",
+           c);
+    return false;
+  }
   std::vector<std::pair<int, int> >::const_iterator ranges_iter;
   ranges_iter = ranges.begin();
   while (ranges_iter != ranges.end()) {
@@ -8578,7 +8596,7 @@
   std::vector<charinfo *>::const_iterator nested_iter;
   nested_iter = nested_classes.begin();
   while (nested_iter != nested_classes.end()) {
-    if ((*nested_iter)->contains(c))
+    if ((*nested_iter)->contains(c, true))
       return true;
     ++nested_iter;
   }
@@ -8586,19 +8604,25 @@
   return false;
 }
 
-bool charinfo::contains(symbol s)
+bool charinfo::contains(symbol s, bool already_called)
 {
+  if (already_called) {
+    warning(WARN_SYNTAX,
+           "cyclic nested class detected while processing symbol %1",
+           s.contents());
+    return false;
+  }
   const char *unicode = glyph_name_to_unicode(s.contents());
   if (unicode != NULL && strchr(unicode, '_') == NULL) {
     char *ignore;
     int c = (int)strtol(unicode, &ignore, 16);
-    return contains(c);
+    return contains(c, true);
   }
   else
     return false;
 }
 
-bool charinfo::contains(charinfo *)
+bool charinfo::contains(charinfo *, bool)
 {
   // TODO
   return false;



reply via email to

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