Text   |  XML   |  ReML   |   Visible Warnings:

Buffer Overrun  at lemon.c:2600

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

Parse

(/home/sate/Testcases/c/cve/wireshark-1.2.0/tools/lemon/lemon.c)expand/collapse
Show more  
 2539  void Parse(struct lemon *gp)
 2540  {
 2541    struct pstate ps;
 2542    FILE *fp;
 2543    char *filebuf;
 2544    long filesize;
 2545    int lineno;
 2546    char c;
 2547    char *cp, *nextcp;
 2548    int startline = 0;
 2549   
 2550    memset(&ps, '\0', sizeof(ps));
 2551    ps.gp = gp;
 2552    ps.filename = gp->filename;
 2553    ps.errorcnt = 0;
 2554    ps.state = INITIALIZE;
 2555    ps.prevrule = NULL;
 2556    ps.preccounter = 0;
 2557    ps.lastrule = NULL;
 2558    ps.firstrule = NULL;
 2559    ps.lhs = NULL;
 2560    ps.nrhs = 0;
 2561    ps.lhsalias = NULL;
 2562    ps.declkeyword = NULL;
 2563    ps.declargslot = NULL;
 2564    ps.declassoc = UNK;
 2565    ps.fallback = NULL;
 2566   
 2567    /* Begin by reading the input file */
 2568    fp = fopen(ps.filename,"rb");
 2569    if( fp==0 ){
 2570      ErrorMsg(ps.filename,0,"Can't open this file for reading.");
 2571      gp->errorcnt++;
 2572      return;
 2573    }
 2574    fseek(fp,0,2);
 2575    filesize = ftell(fp);
 2576    rewind(fp);
 2577    /* XXX - what if filesize is bigger than the maximum size_t value? */
 2578    filebuf = (char *)malloc( filesize+1 );
 2579    if( filebuf==0 ){
 2580      ErrorMsg(ps.filename,0,"Can't allocate %ld of memory to hold this file.",
 2581        filesize+1);
 2582      gp->errorcnt++;
 2583      return;
 2584    }
 2585    if( fread(filebuf,1,filesize,fp)!=(size_t)filesize ){
 2586      ErrorMsg(ps.filename,0,"Can't read in all %ld bytes of this file.",
 2587        filesize);
 2588      free(filebuf);
 2589      gp->errorcnt++;
 2590      return;
 2591    }
 2592    fclose(fp);
 2593    filebuf[filesize] = 0;
 2594   
 2595    /* Make an initial pass through the file to handle %ifdef and %ifndef */
 2596[+]   preprocess_input(filebuf);
 2597   
 2598    /* Now scan the text of the input file */
 2599    lineno = 1;
 2600    for(cp=filebuf; (c= *cp)!=0; ){
 2601      if( c=='\n' ) lineno++;              /* Keep track of the line number */
 2602      if( safe_isspace(c) ){ cp++; continue; }  /* Skip all white space */
 2603      if( c=='/' && cp[1]=='/' ){          /* Skip C++ style comments */
 2604        cp+=2;
 2605        while( (c= *cp)!=0 && c!='\n' ) cp++;
 2606        continue;
Show more  




Change Warning 905.30390 : Buffer Overrun

Priority:
State:
Finding:
Owner:
Note: