[BACK]Return to roff.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/roff.c between version 1.169 and 1.170

version 1.169, 2011/09/18 14:14:15 version 1.170, 2011/09/18 23:51:31
Line 31 
Line 31 
 /* Maximum number of nested if-else conditionals. */  /* Maximum number of nested if-else conditionals. */
 #define RSTACK_MAX      128  #define RSTACK_MAX      128
   
   /* Maximum number of string expansions per line, to break infinite loops. */
   #define EXPAND_LIMIT    1000
   
 enum    rofft {  enum    rofft {
         ROFF_ad,          ROFF_ad,
         ROFF_am,          ROFF_am,
Line 437  roff_res(struct roff *r, char **bufp, size_t *szp, int
Line 440  roff_res(struct roff *r, char **bufp, size_t *szp, int
         const char      *stnam; /* start of the name, after "[(*" */          const char      *stnam; /* start of the name, after "[(*" */
         const char      *cp;    /* end of the name, e.g. before ']' */          const char      *cp;    /* end of the name, e.g. before ']' */
         const char      *res;   /* the string to be substituted */          const char      *res;   /* the string to be substituted */
         int              i, maxl;          int              i, maxl, expand_count;
         size_t           nsz;          size_t           nsz;
         char            *n;          char            *n;
   
           expand_count = 0;
   
 again:  again:
         cp = *bufp + pos;          cp = *bufp + pos;
         while (NULL != (cp = strchr(cp, '\\'))) {          while (NULL != (cp = strchr(cp, '\\'))) {
Line 535  again:
Line 540  again:
   
                 *bufp = n;                  *bufp = n;
                 *szp = nsz;                  *szp = nsz;
                 goto again;  
                   if (EXPAND_LIMIT >= ++expand_count)
                           goto again;
   
                   /* Just leave the string unexpanded. */
                   mandoc_msg(MANDOCERR_ROFFLOOP, r->parse, ln, pos, NULL);
                   return;
         }          }
 }  }
   

Legend:
Removed from v.1.169  
changed lines
  Added in v.1.170

CVSweb