(/home/sate/Testcases/c/cve/wireshark-1.2.0/tools/lemon/lemon.c) |
| |
| 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 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 ){ |
Event 1:
Skipping " if". version evaluates to false.
hide
|
|
| 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 | | | |
| 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 | | | |
| 1498 | | | |
| 1499 | | | |
| 1500 | | | |
| 1501 | | | |
| 1502 | | | lem.outdirname = outdirname; |
| 1503 | | | lem.templatename = templatename; |
| 1504 | | | lem.basename = make_basename(lem.filename); |
| 1505 | | | |
| 1506 | | | |
| 1507 | [+] | | Parse(&lem); |
 |
| 1508 | | | if( lem.errorcnt ) exit(lem.errorcnt); |
Event 13:
Skipping " if". lem.errorcnt evaluates to false.
hide
|
|
| 1509 | | | if( lem.nrule==0 ){ |
Event 14:
Skipping " if". lem.nrule == 0 evaluates to false.
hide
|
|
| 1510 | | | fprintf(stderr,"Empty grammar.\n"); |
| 1511 | | | exit(1); |
| 1512 | | | } |
| 1513 | | | |
| 1514 | | | |
| 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; |
Event 21:
Leaving loop. i <= lem.nsymbol evaluates to false.
hide
|
|
| 1519 | | | qsort(lem.symbols,lem.nsymbol+1,sizeof(struct symbol*), |
Event 22:
lem.symbols, which evaluates to NULL, is passed to qsort() as the first argument. See related event 20.
hide
Null Pointer Dereference
The body of qsort() dereferences lem.symbols, but it is NULL. The issue can occur if the highlighted code executes. See related event 22. Show: All events | Only primary events |
|
| 1520 | | | Symbolcmpp); |
| |