Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Null Pointer Dereference  at tdpro.c:1225

Categories: LANG.MEM.NPD CWE:476
Warning ID: 22095.28958
Procedure: tm_spawn
Trace: view
Modified: Thu Nov 26 11:29: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/pvm3/src/tdpro.c
   Enter tm_spawn
 1083 tm_spawn(tp, mp) 
 1084         struct task *tp;
 1085         struct pmsg *mp;
 1086 {
 1087         char *where = 0;                                /* location from req */ 
 1088         struct waitc *wp;                               /* 'seed' waitc */ 
 1089         struct waitc_spawn *wxp = 0;    /* new task parameters */ 
 1090         struct htab *htp;                               /* set of usable hosts */ 
 1091         struct hostd *hp;
 1092         int hh;
 1093         int i;
 1094         char *wd = 0;
 1095         char *wdenv = 0;
 1096         char *ptr;
 1097         int sz;
 1098  
 1099         /*
 1100         * unpack spawn command from task 
 1101         */ 
 1102  
 1103         wxp = TALLOC(1, struct waitc_spawn, "waix");
 1104         BZERO((char*)wxp, sizeof(struct waitc_spawn));   /* Null Pointer Dereference (ID: 288.28963) */
 1105  
 1106         if (upkstralloc(mp, &wxp->w_file) 
 1107         || upkint(mp, &wxp->w_flags) 
 1108         || upkstralloc(mp, &where) 
 1109         || upkint(mp, &wxp->w_veclen) 
 1110         || upkint(mp, &wxp->w_argc))
 1111                 goto bad;
 1112  
 1113         if (wxp->w_veclen < 1)
 1114                 goto bad;
 1115  
 1116         wxp->w_argv = TALLOC(wxp->w_argc + 1, char*, "argv");   /* Integer Overflow of Allocation Size (ID: 287.28962) */
 1117         BZERO((char*)wxp->w_argv, (wxp->w_argc + 1) * sizeof(char*));   /* Null Pointer Dereference (ID: 286.28961) */
 1118         for (i = 0; i < wxp->w_argc; i++)
 1119                 if (upkstralloc(mp, &wxp->w_argv[i]))
 1120                         goto bad;
 1121  
 1122         if (upkuint(mp, &wxp->w_outtid) 
 1123         || upkuint(mp, &wxp->w_outctx) 
 1124         || upkuint(mp, &wxp->w_outtag) 
 1125         || upkuint(mp, &wxp->w_trctid) 
 1126         || upkuint(mp, &wxp->w_trcctx) 
 1127         || upkuint(mp, &wxp->w_trctag))
 1128                 goto bad;
 1129  
 1130         /*
 1131         * extract any working directory string from "where"
 1132         */ 
 1133  
 1134         ptr = where;
 1135         while ( *ptr != ':' && *ptr != '\0' )
 1136                 ptr++;
 1137         if ( *ptr == ':' ) {
 1138                 *ptr++ = '\0';    /* close off actual "where" string */ 
 1139                 wd = ptr;         /* save ptr to working directory */ 
 1140         }
 1141  
 1142         /*
 1143         * unpack environment from task 
 1144         */ 
 1145  
 1146         if (upkuint(mp, &wxp->w_nenv))
 1147                 goto bad;
 1148         sz = wxp->w_nenv + 1 + (wd ? 1 : 0);
 1149         wxp->w_env = TALLOC(sz, char*, "env");   /* Integer Overflow of Allocation Size (ID: 22097.28960) */
 1150         BZERO((char*)wxp->w_env, sz * sizeof(char*));   /* Null Pointer Dereference (ID: 22096.28959) */
 1151         for (i = 0; i < wxp->w_nenv; i++)
 1152                 if (upkstralloc(mp, &wxp->w_env[i]))
 1153                         goto bad;
 1154  
 1155         /*
 1156         * add extra env string for working directory 
 1157         */ 
 1158  
 1159         if ( wd ) {
 1160                 sz = strlen(wd) + strlen("PVMSPAWNWD=") + 1;
 1161                 wdenv = TALLOC(sz, char, "wdenv");
 1162                 sprintf( wdenv, "PVMSPAWNWD=%s", wd );
 1163                 wxp->w_env[ (wxp->w_nenv)++ ] = STRALLOC( wdenv );
 1164         }
 1165  
 1166         /*
 1167         * make host set containing hosts (matching where option)
 1168         */ 
 1169  
 1170         if ((wxp->w_flags & (PvmTaskHost|PvmTaskArch)) && !where)
 1171                 goto bad;
 1172  
 1173         htp = ht_new(1);
 1174  
 1175         if (wxp->w_flags & PvmTaskHost) {                       /* given host */ 
 1176                 if (hp = nametohost(hosts, where))
 1177                         ht_insert(htp, hp);
 1178  
 1179         } else {
 1180                 if (wxp->w_flags & PvmTaskArch) {               /* given arch */ 
 1181                         for (hh = hosts->ht_last; hh > 0; hh--)
 1182                                 if ((hp = hosts->ht_hosts[hh]) 
 1183                                 && !strcmp(where, hp->hd_arch))
 1184                                         ht_insert(htp, hp);
 1185  
 1186 #ifdef IMA_BEOLIN 
   ...
 1188                 } else if (wxp->w_flags & PvmMppFront) {
 1189                         hp = hosts->ht_hosts[hosts->ht_local];
 1190                         ht_insert(htp, hp); 
 1191 #endif 
 1192  
 1193                 } else {                                                /* anywhere */ 
 1194                         ht_merge(htp, hosts);
 1195                 }
 1196         }
 1197  
 1198         if (wxp->w_flags & PvmHostCompl) {
 1199                 for (hh = hosts->ht_last; hh > 0; hh--) {
 1200                         if (hh <= htp->ht_last && (hp = htp->ht_hosts[hh]))
 1201                                 ht_delete(htp, hp);
 1202                         else 
 1203                                 if (hp = hosts->ht_hosts[hh])
 1204                                         ht_insert(htp, hp);
 1205                 }
 1206         }
 1207  
 1208         if (pvmdebmask & PDMTASK) {
 1209                 pvmlogerror("tm_spawn() host set:\n");
 1210                 ht_dump(htp);
 1211         }
 1212  
 1213         if ( !(wxp->w_flags & PvmNoSpawnParent) ) {
 1214                 wxp->w_ptid = tp->t_tid;
 1215         }
 1216         else 
 1217                 wxp->w_ptid = PvmParentNotSet;  /* indicate task unset parent */ 
 1218  
 1219         /*
 1220         * assign each task to a host 
 1221         */ 
 1222  
 1223         wxp->w_ht = htp;
true1224         wxp->w_vec = TALLOC(wxp->w_veclen, int, "vec");
wxp->w_vec <= 40951225         BZERO((char*)wxp->w_vec, wxp->w_veclen * sizeof(int));     /* Null Pointer Dereference */
Preconditions
&$unknown_908480 >= 1
&$unknown_908500 >= 1
&$unknown_908504 >= 4
&$heap_324551 <= &$unknown_908494
hosts->ht_last >= 2
$unknown_908494 != 0
$unknown_908494 != 58
strlen(&$unknown_908494) = 1
((char*)&$unknown_908494)[1] = 0
((char*)&$heap_324550)[24] = &$unknown_908504 / 4
((char*)&$heap_324550)[24] >= 1
((char*)&$heap_324550)[56] >= 2
$heap_324551 != 0
$heap_324551 <= 46
strlen(&$heap_324551) > 0
Postconditions
errno' != 0
$heap_324550' = 0
bytes_after(&$heap_324550)' = 84
$heap_324550' is allocated by malloc
bytes_before(&$heap_324550)' = 0
((char*)&$heap_324550)[16]' = &$heap_324557
((char*)&$heap_324550)[20]' = 0
((char*)&$heap_324550)[60]' = &$heap_324554
((char*)&$heap_324550)[64]' = -35
((char*)&$heap_324550)[12]' = &$heap_324552
bytes_after(&$heap_324551)' = &$unknown_908480
$heap_324551' is allocated by malloc
bytes_before(&$heap_324551)' = 0
$heap_324552' = 0
$heap_324552' is allocated by malloc
bytes_before(&$heap_324552)' = 0
$heap_324554' = 0
bytes_after(&$heap_324554)' = 4 * ((char*)&$heap_324550)[56] + 4
$heap_324554' is allocated by malloc
bytes_before(&$heap_324554)' = 0
$heap_324557' = 0
bytes_after(&$heap_324557)' = 32
$heap_324557' is allocated by malloc
$heap_324557' is allocated
bytes_before(&$heap_324557)' = 0
((char*)&$heap_324557)[28]' = &$unknown_908501
((char*)&$heap_324557)[4]' = &$unknown_908500
hh' = 0
hp' = ((char*)&$unknown_908501)[4]
htp' = &$heap_324557
i' = ((char*)&$heap_324550)[56]
ptr' = &$unknown_908494 + 1
sz' = ((char*)&$heap_324550)[56] + 1
wd' = 0
wdenv' = 0
where' = &$heap_324551
wxp' = &$heap_324550




Change Warning 22095.28958 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: