Text  |   XML   |   Visible Warnings:

irssi-0.8.14 : irssi-0.8.14 analysis 2 : Null Pointer Dereference  at commands.c:571

Categories: LANG.MEM.NPD CWE:476
Warning ID: 4765.28237
Procedure: get_cmd_options
Trace: view
Modified: Thu Nov 26 11:08:13 2009   show details
 
Priority: None
State: None
Finding: None
Owner: None
  edit properties

Legend [ X ]
Warning Location
Contributes
Parse Error
Other Warning
Two or More Loop Iterations
On Execution Path
Comment
Macro
Preprocessor
Include
Keyword
Preprocessed Away

Source  |  Language: C Hide Legend     
ProblemLineSource
   /kat0/fletcher/SATE/2010/irssi-0.8.14/src/core/commands.c
   Enter get_cmd_options
 557 static int get_cmd_options(char **data, int ignore_unknown,
 558                            const char *cmd, GHashTable *options) 
 559 {
 560         COMMAND_REC *rec;
 561         char *option, *arg, **optlist;
 562         int pos;
 563  
 564         /* get option definitions */ 
 565         rec = cmd == NULL ? NULL : command_find(cmd);
true566         optlist = rec == NULL ? NULL : rec->options;
 567  
 568         option = NULL; pos = -1;
 569         for (;;) {
 570                 if (**data == '-') {
optlist <= 4095571                         if (option != NULL && *optlist[pos] == '+') {     /* Null Pointer Dereference */
 572                                 /* required argument missing! */ 
 573                                 *data = optlist[pos] + 1;
 574                                 return CMDERR_OPTION_ARG_MISSING;
 575                         }
 576  
 577                         (*data)++;
 578                         if (**data == '-' && (*data)[1] == ' ') {
 579                                 /* -- option means end of options even 
 580                                    if next word starts with - */ 
 581                                 (*data)++;
 582                                 while (**data == ' ') (*data)++;
 583                                 break;
 584                         }
 585  
 586                         if (**data == '\0')
 587                                 option = "-";
 588                         else if (**data != ' ')
 589                                 option = cmd_get_param(data);
 590                         else {
 591                                 option = "-";
 592                                 (*data)++;
 593                         }
 594  
 595                         /* check if this option can have argument */ 
 596                         pos = optlist == NULL ? -1 : 
 597                                 option_find(optlist, option);
 598  
 599                         if (pos == -1 && optlist != NULL &&
 600                             is_numeric(option, '\0')) {
 601                                 /* check if we want -<number> option */ 
 602                                 pos = option_find(optlist, "#");
 603                                 if (pos != -1) {
 604                                         g_hash_table_insert(options, "#",
 605                                                             option);
 606                                         pos = -3;
 607                                 }
 608                         }
 609  
 610                         if (pos == -1 && !ignore_unknown) {
 611                                 /* unknown option! */ 
 612                                 *data = option;
 613                                 return CMDERR_OPTION_UNKNOWN;
 614                         }
 615                         if (pos == -2 && !ignore_unknown) {
 616                                 /* multiple matches */ 
 617                                 *data = option;
 618                                 return CMDERR_OPTION_AMBIGUOUS;
 619                         }
 620                         if (pos >= 0) {
 621                                 /* if we used a shortcut of parameter, put 
 622                                    the whole parameter name in options table */ 
 623                                 option = optlist[pos] + 
 624                                         iscmdtype(*optlist[pos]);
 625                         }
 626                         if (options != NULL && pos != -3)
 627                                 g_hash_table_insert(options, option, "");
 628  
 629                         if (pos < 0 || !iscmdtype(*optlist[pos]) ||
 630                             *optlist[pos] == '!')
 631                                 option = NULL;
 632  
 633                         while (**data == ' ') (*data)++;
 634                         continue;
 635                 }
 636  
 637                 if (option == NULL)
 638                         break;
 639  
 640                 if (*optlist[pos] == '@' && !is_numeric(*data, ' '))   /* Null Pointer Dereference (ID: 4764.28236) */
 641                         break; /* expected a numeric argument */ 
 642  
 643                 /* save the argument */ 
 644                 arg = cmd_get_quoted_param(data);
 645                 if (options != NULL) {
 646                         g_hash_table_remove(options, option);
 647                         g_hash_table_insert(options, option, arg);
 648                 }
 649                 option = NULL;
 650  
 651                 while (**data == ' ') (*data)++;
Preconditions
cmd != 0
&$unknown_17839 != 0
$unknown_17838 = 45
strlen(&$unknown_17838) != 0
Postconditions
option' = &$unknown_17839
optlist' = 0
rec' = 0




Change Warning 4765.28237 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: