Text   |  XML   |  ReML   |   Visible Warnings:

Buffer Overrun  at lemon.c:985

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

main

(/home/sate/Testcases/c/cve/wireshark-1.2.0/tools/lemon/lemon.c)expand/collapse
Show more  
 1444  int main(int argc _U_, char **argv)
 1445  {
 1446    static int version = 0;
 1447    static int rpflag = 0;
 1448    static int basisflag = 0;
 1449    static int compress = 0;
 1450    static int quiet = 0;
 1451    static int statistics = 0;
 1452    static int mhflag = 0;
 1453    static char *outdirname = NULL;
 1454    static char *templatename = NULL;
 1455    static struct s_options options[] = {
 1456      {OPT_FLAG, "b", (char*)&basisflag, "Print only the basis in report."},
 1457      {OPT_FLAG, "c", (char*)&compress, "Don't compress the action table."},
 1458      {OPT_STR,  "d", (char*)&outdirname, "Output directory name."},
 1459      {OPT_FSTR, "D", (char*)handle_D_option, "Define an %ifdef macro."},
 1460      {OPT_FLAG, "g", (char*)&rpflag, "Print grammar without actions."},
 1461      {OPT_FLAG, "m", (char*)&mhflag, "Output a makeheaders compatible file"},
 1462      {OPT_FLAG, "q", (char*)&quiet, "(Quiet) Don't print the report file."},
 1463      {OPT_FLAG, "s", (char*)&statistics,
 1464                                     "Print parser stats to standard output."},
 1465      {OPT_STR,  "t", (char*)&templatename, "Template file to use."},
 1466      {OPT_FLAG, "x", (char*)&version, "Print the version number."},
 1467      {OPT_FLAG,0,0,0}
 1468    };
 1469    int i;
 1470    struct lemon lem;
 1471   
 1472    optinit(argv,options,stderr);
 1473    if( version ){
 1474       printf("Lemon version 1.0\n"
 1475         "Copyright 1991-1997 by D. Richard Hipp\n"
 1476         "Freely distributable under the GNU Public License.\n"
 1477       );
 1478       exit(0);
 1479    }
 1480[+]   if( optnargs()!=1 ){
 1481      fprintf(stderr,"Exactly one filename argument is required.\n");
 1482      exit(1);
 1483    }
 1484    memset(&lem, 0, sizeof(lem));
 1485    lem.errorcnt = 0;
 1486   
 1487    /* Initialize the machine */
 1488    Strsafe_init();
 1489[+]   Symbol_init();
 1490[+]   State_init();
 1491    lem.argv0 = argv[0];
 1492    lem.filename = get_optarg(0);
 1493    lem.basisflag = basisflag;
 1494    Symbol_new("$");
 1495    lem.errsym = Symbol_new("error");
 1496    /*
 1497    **  Resetting useCnt in errsym seems to disable some error checking we  
 1498    **  need to validate the filter syntax.  So we remove this resetting for now.
 1499    **
 1500    **  lem.errsym->useCnt = 0;
 1501    */
 1502    lem.outdirname = outdirname;
 1503    lem.templatename = templatename;
 1504    lem.basename = make_basename(lem.filename);
 1505   
 1506    /* Parse the input file */
 1507[+]   Parse(&lem);
 1508    if( lem.errorcnt ) exit(lem.errorcnt);
 1509    if( lem.nrule==0 ){
 1510      fprintf(stderr,"Empty grammar.\n");
 1511      exit(1);
 1512    }
 1513   
 1514    /* Count and index the symbols of the grammar */
 1515    lem.nsymbol = Symbol_count();
 1516    Symbol_new("{default}");
 1517    lem.symbols = Symbol_arrayof();
 1518    for(i=0; i<=lem.nsymbol; i++) lem.symbols[i]->index = i;
 1519    qsort(lem.symbols,lem.nsymbol+1,sizeof(struct symbol*),
 1520          Symbolcmpp);
 1521    for(i=0; i<=lem.nsymbol; i++) lem.symbols[i]->index = i;
 1522    for(i=1; safe_isupper(lem.symbols[i]->name[0]); i++);
 1523    lem.nterminal = i;
 1524   
 1525    /* Generate a reprint of the grammar, if requested on the command line */
 1526    if( rpflag ){
 1527      Reprint(&lem);
 1528    }else{
 1529      /* Initialize the size for all follow and first sets */
 1530      SetSize(lem.nterminal+1);
 1531   
 1532      /* Find the precedence for every production rule (that has one) */
 1533      FindRulePrecedences(&lem);
 1534   
 1535      /* Compute the lambda-nonterminals and the first-sets for every
 1536      ** nonterminal */
 1537      FindFirstSets(&lem);
 1538   
 1539      /* Compute all LR(0) states.  Also record follow-set propagation 
 1540      ** links so that the follow-set can be computed later */
 1541      lem.nstate = 0;
 1542      FindStates(&lem);
 1543[+]     lem.sorted = State_arrayof();
 1544   
 1545      /* Tie up loose ends on the propagation links */
 1546      FindLinks(&lem);
 1547   
 1548      /* Compute the follow set of every reducible configuration */
 1549      FindFollowSets(&lem);
 1550   
 1551      /* Compute the action tables */
 1552[+]     FindActions(&lem);
expand/collapse

FindActions

(/home/sate/Testcases/c/cve/wireshark-1.2.0/tools/lemon/lemon.c)expand/collapse
Show more  
 948  void FindActions(struct lemon *lemp)
 949  {
 950    int i,j;
 951    struct config *cfp;
 952    struct state *stp;
 953    struct symbol *sp;
 954    struct rule *rp;
 955   
 956    /* Add all of the reduce actions
 957    ** A reduce action is added for each element of the followset of
 958    ** a configuration which has its dot at the extreme right.
 959    */
 960    for(i=0; i<lemp->nstate; i++){   /* Loop over all states */
 961      stp = lemp->sorted[i];
 962      for(cfp=stp->cfp; cfp; cfp=cfp->next){  /* Loop over all configurations */
 963        if( cfp->rp->nrhs==cfp->dot ){        /* Is dot at extreme right? */
 964          for(j=0; j<lemp->nterminal; j++){
 965            if( SetFind(cfp->fws,j) ){
 966              /* Add a reduce action to the state "stp" which will reduce by the 
 967              ** rule "cfp->rp" if the lookahead symbol is "lemp->symbols[j]" */
 968              Action_add(&stp->ap,REDUCE,lemp->symbols[j],(char *)cfp->rp);
 969            }
 970          }
 971        }
 972      }
 973    }
 974   
 975    /* Add the accepting token */
 976    if( lemp->start ){
 977      sp = Symbol_find(lemp->start);
 978      if( sp==0 ) sp = lemp->rule->lhs;
 979    }else{
 980      sp = lemp->rule->lhs;
 981    }
 982    /* Add to the first state (which is always the starting state of the 
 983    ** finite state machine) an action to ACCEPT if the lookahead is the 
 984    ** start nonterminal.  */
 985    Action_add(&lemp->sorted[0]->ap,ACCEPT,sp,0);
Show more  
Show more  




Change Warning 12297.30700 : Buffer Overrun

Priority:
State:
Finding:
Owner:
Note: