Text   |  XML   |  ReML   |   Visible Warnings:

Integer Overflow of Allocation Size  at lemon.c:3736

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

ReportTable

(/home/sate/Testcases/c/cve/wireshark-1.2.0/tools/lemon/lemon.c)expand/collapse
Show more  
 3620  void ReportTable(
 3621      struct lemon *lemp,
 3622      int mhflag)     /* Output in makeheaders format if true */
 3623  {
 3624    FILE *out, *in;
 3625    char line[LINESIZE];
 3626    int  lineno;
 3627    struct state *stp;
 3628    struct action *ap;
 3629    struct rule *rp;
 3630    struct acttab *pActtab;
 3631    int i, j, n;
 3632    const char *name;
 3633    int mnTknOfst, mxTknOfst;
 3634    int mnNtOfst, mxNtOfst;
 3635    struct axset *ax;
 3636   
 3637[+]   in = tplt_open(lemp);
 3638    if( in==0 ) return;
 3639[+]   out = file_open(lemp,".c","wb");
 3640    if( out==0 ){
 3641      fclose(in);
 3642      return;
 3643    }
 3644    lineno = 1;
 3645    tplt_xfer(lemp->name,in,out,&lineno);
 3646   
 3647    /* Generate the include code, if any */
 3648    tplt_print(out,lemp,lemp->include,&lineno);
 3649    if( mhflag ){
 3650      char *name = file_makename_using_basename(lemp, ".h");
 3651      fprintf(out,"#include \"%s\"\n", name); lineno++;
 3652      free(name);
 3653    }
 3654    tplt_xfer(lemp->name,in,out,&lineno);
 3655   
 3656    /* Generate #defines for all tokens */
 3657    if( mhflag ){
 3658      const char *prefix;
 3659      fprintf(out,"#if INTERFACE\n"); lineno++;
 3660      if( lemp->tokenprefix ) prefix = lemp->tokenprefix;
 3661      else                    prefix = "";
 3662      for(i=1; i<lemp->nterminal; i++){
 3663        fprintf(out,"#define %s%-30s %2d\n",prefix,lemp->symbols[i]->name,i);
 3664        lineno++;
 3665      }
 3666      fprintf(out,"#endif\n"); lineno++;
 3667    }
 3668    tplt_xfer(lemp->name,in,out,&lineno);
 3669   
 3670    /* Generate the defines */
 3671    fprintf(out,"#define YYCODETYPE %s\n",
 3672      minimum_signed_size_type(0, lemp->nsymbol+5)); lineno++;
 3673    fprintf(out,"#define YYNOCODE %d\n",lemp->nsymbol+1);  lineno++;
 3674    fprintf(out,"#define YYACTIONTYPE %s\n",
 3675      minimum_signed_size_type(0, lemp->nstate+lemp->nrule+5));  lineno++;
 3676    if( lemp->wildcard ){
 3677      fprintf(out,"#define YYWILDCARD %d\n",
 3678         lemp->wildcard->index); lineno++;
 3679    }
 3680    print_stack_union(out,lemp,&lineno,mhflag);
 3681    fprintf(out, "#ifndef YYSTACKDEPTH\n"); lineno++;
 3682    if( lemp->stacksize ){
 3683      fprintf(out,"#define YYSTACKDEPTH %s\n",lemp->stacksize);  lineno++;
 3684    }else{
 3685      fprintf(out,"#define YYSTACKDEPTH 100\n");  lineno++;
 3686    }
 3687    fprintf(out, "#endif\n"); lineno++;
 3688    if( mhflag ){
 3689      fprintf(out,"#if INTERFACE\n"); lineno++;
 3690    }
 3691    name = lemp->name ? lemp->name : "Parse";
 3692    if( lemp->arg && lemp->arg[0] ){
 3693      int i;
 3694      i = (int) strlen(lemp->arg);
 3695      while( i>=1 && safe_isspace(lemp->arg[i-1]) ) i--;
 3696      while( i>=1 && (safe_isalnum(lemp->arg[i-1]) || lemp->arg[i-1]=='_') ) i--;
 3697      fprintf(out,"#define %sARG_SDECL %s;\n",name,lemp->arg);  lineno++;
 3698      fprintf(out,"#define %sARG_PDECL ,%s\n",name,lemp->arg);  lineno++;
 3699      fprintf(out,"#define %sARG_FETCH %s = yypParser->%s\n",
 3700                   name,lemp->arg,&lemp->arg[i]);  lineno++;
 3701      fprintf(out,"#define %sARG_STORE yypParser->%s = %s\n",
 3702                   name,&lemp->arg[i],&lemp->arg[i]);  lineno++;
 3703    }else{
 3704      fprintf(out,"#define %sARG_SDECL\n",name);  lineno++;
 3705      fprintf(out,"#define %sARG_PDECL\n",name);  lineno++;
 3706      fprintf(out,"#define %sARG_FETCH\n",name); lineno++;
 3707      fprintf(out,"#define %sARG_STORE\n",name); lineno++;
 3708    }
 3709    if( mhflag ){
 3710      fprintf(out,"#endif\n"); lineno++;
 3711    }
 3712    fprintf(out,"#define YYNSTATE %d\n",lemp->nstate);  lineno++;
 3713    fprintf(out,"#define YYNRULE %d\n",lemp->nrule);  lineno++;
 3714    if( lemp->errsym->useCnt ){
 3715      fprintf(out,"#define YYERRORSYMBOL %d\n",lemp->errsym->index);  lineno++;
 3716      fprintf(out,"#define YYERRSYMDT yy%d\n",lemp->errsym->dtnum);  lineno++;
 3717    }
 3718    if( lemp->has_fallback ){
 3719      fprintf(out,"#define YYFALLBACK 1\n");  lineno++;
 3720    }
 3721    tplt_xfer(lemp->name,in,out,&lineno);
 3722   
 3723    /* Generate the action table and its associates:
 3724    **
 3725    **  yy_action[]        A single table containing all actions.
 3726    **  yy_lookahead[]     A table containing the lookahead for each entry in 
 3727    **                     yy_action.  Used to detect hash collisions.
 3728    **  yy_shift_ofst[]    For each state, the offset into yy_action for 
 3729    **                     shifting terminals.
 3730    **  yy_reduce_ofst[]   For each state, the offset into yy_action for 
 3731    **                     shifting non-terminals after a reduce.
 3732    **  yy_default[]       Default action for each state.
 3733    */
 3734   
 3735    /* Compute the actions on all states and count them up */
 3736    ax = calloc(lemp->nstate*2, sizeof(ax[0]));
Show more  




Change Warning 924.30311 : Integer Overflow of Allocation Size

Priority:
State:
Finding:
Owner:
Note: