Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Free Null Pointer  at cmds.c:2340

Categories: ALLOC.FNP CWE:590
Warning ID: 526.29313
Procedure: spawn_cmd
Trace: view
Modified: Thu Nov 26 11:37:05 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/console/cmds.c
   Enter spawn_cmd
 2187 spawn_cmd(ac, av) 
 2188         int ac;
 2189         char **av;
 2190 {
 2191         int *tids = 0;
 2192         char *where = 0;
 2193         int flags = PvmNoSpawnParent;
 2194         int count = 1;
 2195         int i;
 2196         int oflg = 0;
 2197         int tflg = 0;
 2198         int app;
 2199         char *ofn = 0;
 2200         char *tfn = 0;
 2201         struct job *jp, *jp2;
 2202         void status_msg();
 2203         void event_dump_hdr();
 2204         void output_dump_hdr();
 2205         int fd;
 2206  
 2207         while (av[1][0] == '-') {
 2208                 if (ac < 3) {
 2209                         fputs("incorrect arg count\n", stdout);
 2210                         return 1;
 2211                 }
 2212                 if (av[1][1] == '~') {
 2213                         flags |= PvmHostCompl;
 2214                         av[1]++;
 2215                 }
 2216                 if (av[1][1] == '.' || islower(av[1][1])) {   /* Negative Character Value (ID: 17.28599) */
 2217                         where = av[1] + 1;
 2218                         flags |= PvmTaskHost;
 2219                 }
 2220                 if (av[1][1] == ':')
 2221                         where = av[1] + 1;
 2222                 if (isupper(av[1][1])) {   /* Negative Character Value (ID: 18.28600) */
 2223                         where = av[1] + 1;
 2224                         flags |= PvmTaskArch;
 2225                 }
 2226                 if (av[1][1] == '?')
 2227                         flags |= PvmTaskDebug;
 2228                 if (isdigit(av[1][1]))   /* Negative Character Value (ID: 19.28601) */
 2229                         count = atoi(av[1] + 1);
 2230                 if (av[1][1] == '>') {
 2231                         oflg = 1;
 2232                         app = 0;
 2233                         ofn = av[1] + 2;
 2234                         if (av[1][2] == '>') {
 2235                                 app = 1;
 2236                                 ofn++;
 2237                         }
 2238                         if (!*ofn)
 2239                                 ofn = 0;
 2240 /*
 2241                         printf("%s to %s\n", (app ? "Append" : "Write"),
 2242                                         (ofn ? ofn : "(console)"));
 2243 */ 
 2244                 }
 2245                 if (av[1][1] == '@') {
 2246                         tflg = 1;
 2247                         tfn = av[1] + 2;
 2248                         if (!*tfn)
 2249                                 tfn = "";
 2250                 }
 2251                 /* gnu-like host (where) arg, allows IP's to be used... */ 
 2252                 if (av[1][1] == '-') {
 2253                         if ( !strncmp( &(av[1][2]), "host=", 5 ) ) {
 2254                                 where = av[1] + 7;
 2255                                 flags |= PvmTaskHost;
 2256                         }
 2257                 }
 2258                 av++;
 2259                 ac--;
 2260         }
 2261         if (tflg) {
 2262                 jp2 = job_new(nextjob);
 2263                 jp2->j_flag |= JOB_TRACE;
 2264                 jp2->j_trcid = trc_get_tracer_id();
 2265                 jp2->j_trcid->status_msg = status_msg;
 2266                 if (tfn && !strcmp(tfn,""))
 2267                         jp2->j_trcid->event_dump_hdr = event_dump_hdr;
 2268                 if (oflg && !ofn) ofn = "";
 2269                 if (ofn)
 2270                         jp2->j_trcid->output_dump_hdr = output_dump_hdr;
 2271                 jp2->j_trcid->event_ctx = pvm_getcontext();
 2272                 jp2->j_trcid->event_tag = nextjob;
 2273                 jp2->j_trcid->output_ctx = pvm_getcontext();
 2274                 jp2->j_trcid->output_tag = nextjob + 1;
 2275                 trc_set_tracing_codes( jp2->j_trcid );
 2276                 printf("[%d]\n", nextjob - joboffset);
 2277                 nextjob += 2;
 2278                 trc_set_trace_file( jp2->j_trcid, tfn );
 2279                 if (!trc_reset_trace_file( jp2->j_trcid )) {
 2280                         job_free(jp2);
 2281                         return 1;
 2282                 }
 2283                 trc_save_host_status_events( jp2->j_trcid );
 2284                 if (ofn) {
 2285                         trc_set_output_file( jp2->j_trcid, ofn );
 2286                         if (!trc_open_output_file( jp2->j_trcid )) {
 2287                                 job_free(jp2);
 2288                                 return 1;
 2289                         }
 2290                 }
 2291                 oflg = 0;
 2292         }
 2293         else {
 2294                 pvm_setopt(PvmTraceTid, 0);
 2295  
 2296                 if (oflg) {
 2297                         pvm_setopt(PvmOutputTid, mytid);
 2298                         pvm_setopt(PvmOutputContext, pvm_getcontext());
 2299                         pvm_setopt(PvmOutputCode, nextjob);
 2300                         jp = job_new(nextjob);
 2301                         printf("[%d]\n", nextjob - joboffset);
   ...
 2317                                 if (!jp->j_ff) {
 2318                                         perror(ofn);
 2319                                         job_free(jp);
 2320                                         return 1;
 2321                                 }
 2322                         }
 2323                 } else 
 2324                         pvm_setopt(PvmOutputTid, 0);
 2325         }
 2326  
true2327         tids = TALLOC(count > 1 ? count : 1, int, "int");   /* Integer Overflow of Allocation Size (ID: 525.29316) */
 2328         if ((i = pvm_spawn(av[1], &av[2], flags, where, count, tids)) >= 0) {
 2329                 if (oflg & !i)
 2330                         job_free(jp);
 2331                 if (tflg & !i)
 2332                         job_free(jp2);
 2333                 printf("%d successful\n", i);
 2334                 for (i = 0; i < count; i++)
 2335                         if (tids[i] < 0)   /* Uninitialized Variable (ID: 523.29315) */  /* Null Pointer Dereference (ID: 524.29314) */
 2336                                 printf("%s\n", PVMERRMSG(tids[i]));
 2337                         else 
 2338                                 printf("t%x\n", tids[i]);
 2339         }
tids <= 40952340         MY_FREE(tids);     /* Free Null Pointer */
Preconditions
ac >= 4
&$unknown_12297780 <= ac
&$unknown_12297780 >= 4
&$unknown_12297781 >= av
&$unknown_12297782 != 0
&$unknown_12297783 != 0
&$unknown_12297790 != 0
&$unknown_12297795 != 0
&$unknown_12297796 >= 1
joblist->j_link->j_ff != 0
joblist->j_link->j_jid = nextjob
((char*)&((char*)$unknown_12297781)[8])[1] = 45
*av[1] = 45
strlen(av[1]) != 0
((char*)$unknown_12297781)[4] = 45
strlen(((char*)&$unknown_12297781)[4]) != 0
((char*)$unknown_12297781)[8] = 45
strlen(((char*)&$unknown_12297781)[8]) = 7
((char*)$unknown_12297781)[12] != 45
TRC_HOST_LIST >= 0
pvmtoplvl != 0
Postconditions
joblist->j_link->j_link->j_rlink' = joblist->j_link->j_rlink
joblist->j_link->j_trcid' = &$heap_446203
joblist->j_link->j_rlink' = 0
joblist->j_link->j_rlink->j_link' = joblist->j_link->j_link
*joblist->j_link->j_ff->_flags' is freed
joblist->j_link->j_link' = 0
*joblist->j_link' is freed
TRC_HOST_LIST' = &$unknown_12297791
TRC_ID_LIST' = &$heap_446203
ac' = &$unknown_12297780 - 2
av' = &$unknown_12297781 + 8
codesonar_distance_tweak' = 2
count' <= 0
errno' != 0
bytes_after(&$heap_446203)' = 96
$heap_446203' is allocated by malloc
bytes_before(&$heap_446203)' = 0
((char*)&$heap_446203)[40]' = &$heap_446205
bytes_after(&$heap_446205)' = strlen(&$unknown_12297785) + 1
$heap_446205' is allocated by malloc
$heap_446205' is allocated
bytes_before(&$heap_446205)' = 0
strlen(&$heap_446205)' = strlen(&$unknown_12297785)
i' = 0
jp2' = joblist->j_link
nextjob' = nextjob + 2
oflg' = 0
ofn' = &$unknown_12297785
tflg' = &$unknown_12297783
tfn' = &$unknown_12297784
tids' = 0
where' = ((char*)&$unknown_12297781)[8] + 7




Change Warning 526.29313 : Free Null Pointer

Priority:
State:
Finding:
Owner:
Note: