Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Null Pointer Dereference  at host.c:889

Categories: LANG.MEM.NPD CWE:476
Warning ID: 193.28819
Procedure: readhostfile
Trace: view
Modified: Thu Nov 26 11:28:07 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/pvm3/src/host.c
   Enter readhostfile
 820 struct htab * 
 821 readhostfile(fn) 
 822         char *fn;
 823 {
 824         struct htab *htp;
 825         struct hostd *hp;
 826         FILE *ff = 0;
 827         char buf[512];          /* line buffer */ 
 828         int lnum = 0;           /* line counter */ 
 829         int err = 0;            /* error count */ 
 830         struct hostent *he;
 831         char *p;
 832         struct in_addr *my_in_addrs;
 833         int num_addrs;
 834         int i;
 835         int maxhostid = tidhmask >> (ffs(tidhmask) - 1);
 836         struct hostd *defaults = 0;
 837  
 838         htp = ht_new(1);
 839  
 840         /*
 841         * get list of this host's interfaces so we can detect ourself in file 
 842         */ 
 843  
 844         if (iflist(&my_in_addrs, &num_addrs) == -1 || num_addrs < 1) {
 845                 pvmlogprintf("readhostfile() iflist failed\n");
 846                 goto bail;
 847         }
 848  
 849         if (!(ff = fopen(fn, "r"))) {
 850                 pvmlogprintf("readhostfile() %s: can't read\n", fn);
 851                 goto bail;
 852         }
 853  
 854         /* parse each line of host file */ 
 855  
 856         while (fgets(buf, sizeof(buf), ff)) {
 857                 lnum++;
 858                 for (p = buf; *p && isspace(*p); p++);   /* Negative Character Value (ID: 1.28573) */
 859  
 860                 if (!*p || *p == '#')   /* leading '#' is comment */ 
 861                         continue;
 862  
 863                 if (lnum > maxhostid) {
 864                         pvmlogprintf("readhostfile() %s: too many lines\n", fn);
 865                         err++;
 866                         break;
 867                 }
true868                 hp = hd_new(lnum);
 869  
 870                 while (*p == '&' || *p == '$') {
 871                         if (*p == '&')          /* leading '&' is no-start */ 
 872                                 hp->hd_flag |= HF_NOSTART;   /* Null Pointer Dereference (ID: 196.28822) */
 873                         if (*p == '$')          /* leading '$' allows overloading host */ 
 874                                 hp->hd_flag |= HF_OVERLOAD;   /* Null Pointer Dereference (ID: 194.28820) */
 875                         p++;
 876                 }
 877  
 878                 if (parsehost(p, hp)) {
 879                         pvmlogprintf("readhostfile() %s %d: errors\n", fn, lnum);
 880                         err++;
 881                         goto badline;
 882                 }
 883  
 884         /*
 885         * if host == "*", change the default options 
 886         * instead of adding a new host to the list 
 887         */ 
 888  
hp <= 4095889                 if (!strcmp(hp->hd_name, "*")) {     /* Null Pointer Dereference */
Preconditions
&$unknown_692288 >= 1
&$unknown_692289 != 0
&$unknown_692289 != 35
&$unknown_692289 != 36
&$unknown_692289 != 38
&$unknown_692290 >= 1
$input_884 <= 511
$input_884 >= 1
$input_892 = &$unknown_692289
Postconditions
defaults' = 0
err' = 0
ff' = &$heap_74294
$heap_74291' = 0
bytes_after(&$heap_74291)' = 32
$heap_74291' is allocated by malloc
$heap_74291' is allocated
bytes_before(&$heap_74291)' = 0
((char*)&$heap_74291)[28]' = &$heap_74292
((char*)&$heap_74291)[4]' = 1
$heap_74292' = 0
bytes_after(&$heap_74292)' = 8
$heap_74292' is allocated by malloc
$heap_74292' is allocated
bytes_before(&$heap_74292)' = 0
$heap_74293' is allocated by open
$heap_74293' is allocated
$heap_74294' = &$heap_74293 - 4096
bytes_after(&$heap_74294)' = 1028
$heap_74294' is allocated by fopen
$heap_74294' is allocated
bytes_before(&$heap_74294)' = 0
hp' = 0
htp' = &$heap_74291
lnum' = 1
maxhostid' = &$unknown_692290
num_addrs' = &$unknown_692288
p' = &buf[0]




Change Warning 193.28819 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: